Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using --path option ignores the root folder config file #105

Open
mgrebenets opened this issue May 30, 2019 · 7 comments
Open

Using --path option ignores the root folder config file #105

mgrebenets opened this issue May 30, 2019 · 7 comments

Comments

@mgrebenets
Copy link

Hi there

So I'm facing the issue which is actually very common for all other linters and formatters, such as SwiftLint and SwiftFormat.

I've created a file called .iblinter.yml in my project root folder, and I choose to ignore all storyboards in Example/Storyboards path.

excluded:
 - Example/Storyboards

This all works as expected if I just run iblinter in the root folder.

But, if I use --path option, e.g. iblinter --path Example, then IBLinter ignores my config file even if I run this command from the project root.

As I said, this is not something specific for IBLinter, SwiftFormat and SwiftLint have same behavior.
While I must say rubocop is different and respects config files from the project root.

With SwiftLint and SwiftFormat I was able to use -c / --config option and tell the tools that doesn't matter which paths I want to check, they still should use specific config file.

IBLinter is missing the -c / --config option though.

Could this option be added?

Then I would be able to run

iblinter --config $(pwd)/.iblinter.yml --path Example

and all my custom rules / exclude paths defined in the config will still apply

@phimage
Copy link
Member

phimage commented May 30, 2019

there is no "project root"
there si current path, or paths given by options

so yes adding --config is a good feature
but the path in "excluded" must relative to this config file parent folder or the --path, that is the question!

@mgrebenets
Copy link
Author

I agree with the points, there's no such thing as root folder.

I personally like rubocop behavior more, where exclude paths are relative to the location of the config file, and not to the location specified by --path option.

Regardless, it would be nice to have --config option that behaves same way the SwiftLint's --config option behaves.

I've changed the title to make this a feature request rather than issue with --path.

@phimage
Copy link
Member

phimage commented Jun 3, 2019

--config is now merged, but not released (need to fix the bug about watchkit before)

@phimage
Copy link
Member

phimage commented Jun 3, 2019

@mgrebenets could you test new option --config
if you know how to compile (we use SPM)

I am wondering how rules path must be managed, according to "--path" so the files must contains

excluded:
 - Storyboards

and not

Example/Storyboards

I think the best is to do like swiftlint...

@phimage
Copy link
Member

phimage commented Jun 3, 2019

I make some test with swiftlint on this project which defined - Sources

$ swiftlint --path Sources/ --config $(pwd)/.swiftlint.yml 
Loading configuration from '/Users/phimage/Dev/GitHub/IBLinter/.swiftlint.yml'
Linting Swift files at paths Sources/
No lintable files found at paths: 'Sources/'

So he look files according to "--path" option, the working directory (so Sources/Sources and find nothing)

@mgrebenets
Copy link
Author

What I get with the tests is this:

The storyboard I want to ignore is Apps/MyApp/WatchKitApp/Shared/Base.lproj/Interface.storyboard
So I put this in my .iblinter.yml:

excluded:
 - Apps/MyApp/WatchKitApp/Shared

When running from the location of the config:

# From location of .iblinter.yml
iblinter --config $(pwd)/.iblinter.yml
# or
iblinter

The file gets ignored as expected.

When running like so:

iblinter --config $(pwd)/.iblinter.yml --path Apps/MyApp/WatchKitApp/Shared

the file is linted.

I think this is how SwiftLint is behaving.

Overall, the main reason I wanted to ignore storyboard is because it was crashing (#104). Now when there is no crash, it becomes less critical.

@phimage
Copy link
Member

phimage commented Jun 4, 2019

So we could do better than swiftlint by making an other option in command or in configuration file, to specify that file path are relative to configuration file, and not working directory
But I have no time for this, if someone want to do it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants