Swiftlint: Problem when SwiftLint loads ".swiftlint.yml"

Created on 8 Feb 2016  ·  15Comments  ·  Source: realm/SwiftLint

Hello every one!

I am having problem with SwiftLint at version 0.7.2 and I can't build my project on Xcode 7.2, when I include the ".swiftlint.yml" file at the root of project, the follow message appears

Loading configuration from '.swiftlint.yml'
No lintable files found at path ''
Command /bin/sh failed with exit code 1

But build the project without the file ".swiftlint.yml" run right, but I need specify some rules.

Any clues on what this issue might be?

Thanks for all!!!!

question

Most helpful comment

I just updated to xcode 10.2 and surprisingly ran into this problem, even with the default config file.

What helped for me was to comment out the Sources directory in the config file, like so:

included: # paths to include during linting. `--path` is ignored if present.
#  - Source

All 15 comments

Can you please post the contents of your .swiftlint.yml file?

Of course!

disabled_rules: # rule identifiers to exclude from running
  - colon
  - comma
  - control_statement
opt_in_rules: # some rules are only opt-in
  - empty_count
  - missing_docs
  # Find all the available rules by running:
  # swiftlint rules
included: # paths to include during linting. `--path` is ignored if present.
  - Source
excluded: # paths to ignore during linting. Takes precedence over `included`.
  - Carthage
  - Pods
  - Source/ExcludedFolder
  - Source/ExcludedFile.swift

# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning # implicitly
force_try:
  severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 110
# they can set both implicitly with an array
type_body_length:
  - 300 # warning
  - 400 # error
# or they can set both explicitly
file_length:
  warning: 500
  error: 1200
# naming rules can set warnings/errors for min_length and max_length
# additionally they can set excluded names
type_name:
  min_length: 4 # only warning
  max_length: # warning and error
    warning: 40
    error: 50
  excluded: iPhone # excluded via string
variable_name:
  min_length: # only min_length
    error: 4 # only error
  excluded: # excluded via string array
    - id
    - URL
    - GlobalAPIKey
reporter: "csv" # reporter type (xcode, json, csv, checkstyle)

I've try this version too and nothing

disabled_rules: # rule identifiers to exclude from running
  - colon
  - comma
  - control_statement
opt_in_rules: # some rules are only opt-in
  - empty_count
  - missing_docs
  # Find all the available rules by running:
  # swiftlint rules
included: # paths to include during linting. `--path` is ignored if present.
  - Source
excluded: # paths to ignore during linting. Takes precedence over `included`.
  - Carthage
  - Pods
  - Source/ExcludedFolder
  - Source/ExcludedFile.swift

Thanks for all

What's the contents of your Source directory? Are there Swift files in Source other than in ExcludedFolder or ExcludedFile.swift?

Reproduced this problem when a project has spaces in the name/path. If the spaces are removed, it works fine.

@itsalan could you share more complete steps to reproduce?.

@jpsim Sure. Create a new project, name it something like "Test Project". In the .swiftlint.yml, add/replace these lines (or something similar referencing the path with spaces):

included: 
  - Test\ Project

excluded: 
   - Test\ Project/AppDelegate.swift

SwiftLint will give you the error referenced above now. It will run if the spaces are removed in the project path/folders, or if you remove the included/excluded configuration.

That's because you shouldn't escape the string in your YAML file. YAML syntax already escapes spaces in strings, so it treats \ as a literal character.

Change your YAML file to this:

included:
  - Test Project
excluded:
  - Test Project/AppDelegate.swift

To be very clear, I'm still waiting on steps to reproduce this issue. I can't trigger the behavior described here by following these steps:

$ tree -a
.
├── .swiftlint.yml
└── Test\ Project
    ├── AppDelegate.swift
    └── main.swift

1 directory, 3 files
$ cat .swiftlint.yml
included:
  - Test Project
excluded:
  - Test Project/AppDelegate.swift
$ cat "Test Project/AppDelegate.swift"
let a = 0
$ cat "Test Project/main.swift"
let b = 0
$ swiftlint
Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'main.swift' (1/1)
Test Project/main.swift:1:1: error: Variable Name Violation: Variable name should be between 3 and 40 characters long: 'b' (variable_name)
Done linting! Found 1 violation, 1 serious in 1 file.

I had the same problem and I don't know if it helps but I changed the .swiftlint.yml file to the equivalent of the "Test Project" folder and it started working. So from:

├── .swiftlint.yml └── Test\ Project ├── AppDelegate.swift └── main.swift
to:
└── Test\ Project ├── .swiftlint.yml ├── AppDelegate.swift └── main.swift

EDIT: I LIED, IT JUST DIDN'T THREW AN ERROR :(

@NSCabezon I'm sorry you're having trouble, but as indicated in a few comments in this thread, we have yet to get steps to reproduce. Care to share?

I had the same issue but I solved it by using quotes: "Abc def". Don't forget the quotes!

Closing as we never got steps to reproduce this.

Commenting - Source solve this issue here.

I encountered this issue as well. I put the .swiftlint.yml at the root of the project. Fixed with changing:

included: # paths to include during linting. `--path` is ignored if present.
    - Source
excluded: # paths to ignore during linting. Takes precedence over `included`.
    - Carthage
    - Pods
    - Source/ExcludedFolder
    - Source/ExcludedFile.swift
    - Source/*/ExcludedFile.swift # Exclude files with a wildcard

to

included: # paths to include during linting. `--path` is ignored if present.
    - Sources
excluded: # paths to ignore during linting. Takes precedence over `included`.
    - Carthage
    - Pods
    - Sources/ExcludedFolder
    - Sources/ExcludedFile.swift
    - Sources/*/ExcludedFile.swift # Exclude files with a wildcard

Because I found my project use Sources and Tests instead of Source and Test. Not sure if this is the correct solution to this issue.

I just updated to xcode 10.2 and surprisingly ran into this problem, even with the default config file.

What helped for me was to comment out the Sources directory in the config file, like so:

included: # paths to include during linting. `--path` is ignored if present.
#  - Source

Was this page helpful?
0 / 5 - 0 ratings