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

Issue with rules configuration after updating to 0.54.0 #5347

Closed
2 tasks done
Mucha92 opened this issue Nov 13, 2023 · 6 comments
Closed
2 tasks done

Issue with rules configuration after updating to 0.54.0 #5347

Mucha92 opened this issue Nov 13, 2023 · 6 comments
Labels

Comments

@Mucha92
Copy link

Mucha92 commented Nov 13, 2023

New Issue Checklist

Describe the bug

After updating to version 0.54.0 a following problem appears:

[...]
warning: Invalid configuration for 'type_name'. Falling back to default.
[...]
ApplicationUtils.swift:34:12: error: Type Name Violation: Type name 'MIME_TYPES' should only contain alphanumeric and other allowed characters (type_name)

My configuration file (swiftlint.yml) contains the following lines:

type_name:
  allowed_symbols: "_"
  min_length: 3
  severity: warning

Did somethign change? Should I somehow update my configuration file? On 0.53.0 works fine.

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.54.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? CocoaPods
  • Are you using nested configurations?
    If so, paste their relative paths and respective contents. No
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 14.2 Build version 14C18
@jessesquires
Copy link

jessesquires commented Nov 13, 2023

I think you want this:

type_name:
   allowed_symbols: ['_']
   min_length: 3
   severity: warning

@Mucha92
Copy link
Author

Mucha92 commented Nov 14, 2023

Unfortunately it didn't help :(

Here's the simplified example of problem reproduction:

.
├─ test.swift
├─ .swiftlint.yml
├─ 53
│   └─ swiftlint
└─ 54
    └─ swiftlint

test.swift:

class TestClass {
    struct ALLOWED_NAME {
    }
}

.swiftlint.yml:

identifier_name:
  allowed_symbols: ['_']
  min_length: 3
  max_length: 50
  severity: warning

type_name:
  allowed_symbols: ['_']
  min_length: 3
  severity: warning

result for 0.53.0:

./53/swiftlint version && ./53/swiftlint --config .swiftlint.yml
0.53.0
Linting Swift files in current working directory
Linting 'test.swift' (1/1)
Done linting! Found 0 violations, 0 serious in 1 file.

result for 0.54.0:

./54/swiftlint version && ./54/swiftlint --config .swiftlint.yml
0.54.0
warning: Invalid configuration for 'type_name'. Falling back to default.
Linting Swift files in current working directory
Linting 'test.swift' (1/1)
[...]/test.swift:2:12: error: Type Name Violation: Type name 'ALLOWED_NAME' should only contain alphanumeric and other allowed characters (type_name)
Done linting! Found 1 violation, 1 serious in 1 file.

I've noticed that if I change test.swift to:

class TestClass {
    let ALLOWED_NAME = 1
}

it works fine for both versions. So the issue seems to be related to interpretation of struct keyword

@Rvaler
Copy link

Rvaler commented Nov 14, 2023

I'm facing a similar issue with the nesting property. This is my setup:

nesting:
  type_level:
    warning: 2
  statement_level:
    warning: 10

But when running swiflint rules nesting I'm getting the following message:

warning: Invalid configuration for 'nesting'. Falling back to default.
Nesting (nesting): Types should be nested at most 1 level deep, and functions should be nested at most 2 levels deep.

@SimplyDanny
Copy link
Collaborator

SimplyDanny commented Nov 14, 2023

statement_level was renamed to function_level back in November 2020 and a deprecation warning must have been printed to the console since then upon every use. Now, function_level is the only accepted variant.

@SimplyDanny
Copy link
Collaborator

@Mucha92: In your configuration, severity is an invalid key. The severity is specified via min_length and max_length like:

min_length:
  warning: 3
  error: 2

Using min_length: 3 only configures the warning level.

@Mucha92
Copy link
Author

Mucha92 commented Nov 15, 2023

Thank you, it solves problem

@Mucha92 Mucha92 closed this as completed Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants