-
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
Custom Rules in nested configuration #1815
Comments
To reproduce it, create a file called #!/usr/bin/env sh
mkdir Issue1815
cd Issue1815
touch .swiftlint.yml
mkdir Tests
cd Tests
cat > .swiftlint.yml << EOF
custom_rules:
quickspec_class_name:
name: "Invalid Test Class Name"
regex: "class\\\\s+(.*)[^Tests]:\\\\s+QuickSpec"
message: "A test class name must end with 'Tests'"
severity: error
EOF
cat > FooTests.swift << EOF
// This triggers a violation:
class Foo: QuickSpec { }
// Doesn't trigger a violation:
class FooTests: QuickSpec { }
EOF Then run |
Could reproduce it, but I needed to change |
This issue appears for me when configuring a standard (non custom) rule in a nested configuration also. |
To reproduce it, create a file called issue1815-StandardRule.sh and paste the following:
Then run |
Hi there, I'm also experiencing the same issue. When can we expect a fix? |
The reason that doesn't work is because of the way swiftlint currently handles merges. It is not a true 'merge' of the rules and it's values but a 'union' of rules by identifiers. In @kenthumphries case:
If you want to restore the original behaviour of a "nested config replacing the root config", please take a look at my open PR #2245 @marcelofabri I feel this has regressed somewhere along the way. Let me know if you want me to raise a bug. Reference
|
…Lint#1815). Installed 0.21.0 via CocoaPods.
…Lint#1815). Installed 0.21.0 via CocoaPods.
Fixed in #2556 |
New Issue Checklist
Bug Report
I'm using a custom rule to validate the name of my Quick Specs (I want them to end with
Tests
, e.g.AppCordinatorTests
). For that, I implemented a simple custom rule and placed it in the.swiftlint.yml
that I have inside the Tests directory. It didn't work. So I moved the custom rule to the top level.swiftlint.yml
and it worked.Apparently custom rules don't work if placed in nested configurations.
Environment
swiftlint version
to be sure)? 0.22.0Are you using nested configurations? Yes, I am.
Which Xcode version are you using (check
xcode-select -p
)? Xcode 9b6 (App and Command Line)The text was updated successfully, but these errors were encountered: