-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Unable to set type_body_length
function_body_length
file_length
only as warnings with no error.
#5822
Comments
Can you provide a small reproducer? For me, this works. The configurations type_body_length:
warning: 40
type_body_length:
warning: 40
error: 50
type_body_length: 40
type_body_length: [40, 50] work as I'd expect. |
Can't reproduce either outside of the main project, the same file that fails on the main project does't if isolated. I also noticed that it doesn't happen on our CI. I wonder if it's due to some caching or derived data issue? It's a very large project. Anyways I think the issue is solved, as it doesn't happen on CI where we enforce the linting. Do you have any insights on why this might happen locally and how to avoid it? Just to leave some pointers to other folks having similar issues. Thanks @SimplyDanny! |
How do you call SwiftLint in all these cases? Command line, plugin, Bazel, ...? Can it be that the configuration isn't read at all in your main project? Or are other options considered? |
When testing locally I just run the above command on cli, which doesn't work as expected for some reason. On CI we use GitHub actions with Danger, which works as expected. In both cases I'm sure the config is read. |
Something must be different though. Hard to believe, that the same tool version with the same configuration and code base behaves differently. Did you try running SwiftLint from the command line in CI as well? |
Without even getting CI involved, all I have to do is copy the same file + config in a new folder and it will work, while it wouldn't on the main project. I wonder if SwiftLint takes advantage of Xcode derived data or some other caching that could explain this? |
It shouldn't as it builds its own cache. However, caching is a good point. Try running the command with the |
I found the culprit: we had a duplicated and outdated config file in a subfolder of a test target. Apparently SwiftLint from the cli was picking that up instead than the main one. Since the limits were the same of the default config, I assumed it was picking up the default config instead. This explains also why on CI it was working, since there we explicitly set the path for the config. I'll close this, thanks for your help and insights @SimplyDanny |
New Issue Checklist
Bug Description
I'm trying to set
type_body_length
function_body_length
file_length
to be warning only with custom length. I want to have a warning if the length reaches a certain limit, but no errors.This is not clearly documented, but should be available #1647 #1691
I'm testing this by running:
And I would expect no errors in the output, but I do get errors using the default error limit of the respective rule.
I tried the following variations:
but none is working. It either gets the defults value of the rule:
or gives me:
Environment
The text was updated successfully, but these errors were encountered: