Ilias Karim
Ilias Karim

Reputation: 5397

SwiftLint: how to configure rule severity for a rule with warning and error configurations

I would like to configure the Swiftlint cyclomatic_complexity rule to always have the severity level of warning.

Here are the approaches I have tried in the .swiftlint.yml.

cyclomatic_complexity: warning
cyclomatic_complexity: 
  severity: warning

Both of these yield the same result. Namely, upon running swiftlint, before linting it prints the following error.

Invalid configuration for 'cyclomatic_complexity'. Falling back to default.

How do you configure the severity of this rule for swiftlint, so that it only generates warnings and not errors?

Upvotes: 0

Views: 1786

Answers (3)

Konstantin Stolyarenko
Konstantin Stolyarenko

Reputation: 136

It might be different depending on your SwiftLint version, for me this one works:

cyclomatic_complexity:
  ignores_case_statements: true

Upvotes: 0

Buxlan
Buxlan

Reputation: 21

Try this in .swiftlint.yml, it works for me:

cyclomatic_complexity:
warning: 10
error: 20

Upvotes: 0

Ilias Karim
Ilias Karim

Reputation: 5397

# .swiftlint.yml
cyclomatic_complexity: 20

Upvotes: 0

Related Questions