SwiftLint doesn't produce any warnings while code has a lot of of them

434 views Asked by At

I've installed SwiftLint 0.53.0 into my pet project:

export PATH="$PATH:/opt/homebrew/bin"
if which swiftlint > /dev/null; then
    swiftlint --fix
else
  echo "Error! Swiftlint is not installed"
  exit 1
fi

It starts linting:

SwiftLint starts linting

But it doesn't produce any output while I definitely know it should.

.swiftlint.yml contains correct project path and reporter option set to "Xcode".

I tried changing it to "html" but it doesn't produce any html files.

Of course, there's --fix option activated but there are lint warnings that it can't automatically fix. So they definitely should be shown as warnings.

Please help me. I've searched a lot about this issue but unfortunately didn't find anything.

Thank you.

// Thank to son, config is attached:

# https://bitbucket.app.local/projects/ITD/repos/swift-style-guide/browse/swiftlint.yml
# https://github.com/realm/SwiftLint
opt_in_rules:
  - anyobject_protocol
  - closure_body_length
  - closure_end_indentation
  - closure_spacing
  - collection_alignment
  - convenience_type
  - explicit_init
  - empty_count
  - fatal_error_message
  - first_where
  - force_unwrapping
  - implicitly_unwrapped_optional
  - joined_default_parameter
  - lower_acl_than_parent
  - missing_docs
  - modifier_order
  - multiline_arguments
  - multiline_arguments_brackets
  - multiline_function_chains
  - multiline_literal_brackets
  - multiline_parameters
  - multiline_parameters_brackets
  - operator_usage_whitespace
  - overridden_super_call
  - private_action
  - private_outlet
  - prohibited_super_call
  - redundant_type_annotation
  - switch_case_on_newline
  - trailing_closure
  - unneeded_parentheses_in_closure_argument
  - untyped_error_in_catch
  - vertical_parameter_alignment_on_call
  - vertical_whitespace_closing_braces

included:
  - BFB

excluded:
  - Carthage
  - Pods

analyzer_rules:
  - explicit_self

cyclomatic_complexity:
  ignores_case_statements: true
trailing_closure:
  only_single_muted_parameter: true
missing_docs:
  warning:
    - public
    - open
trailing_semicolon: error
empty_count:
  only_after_dot: true
closing_brace: error
opening_brace:
  severity: error
statement_position:
  severity: error
colon:
  severity: error
return_arrow_whitespace: error
comma: error
vertical_parameter_alignment: error
vertical_parameter_alignment_on_call: error
anyobject_protocol: error
private_outlet:
  allow_private_set: true
lower_acl_than_parent: error
operator_usage_whitespace:
  severity: error
  skip_aligned_constants: false
collection_alignment:
  severity: error
redundant_type_annotation: error
multiline_arguments:
  severity: error
  first_argument_location: next_line
  only_enforce_after_first_closure_on_first_line: true
multiline_arguments_brackets: error
multiline_parameters_brackets: error
multiline_literal_brackets: error
multiline_function_chains: error
modifier_order:
  preferred_modifier_order: [acl, setterACL, override, dynamic, mutators, lazy, final, required, convenience, typeMethods, owned]

custom_rules:
  rus_characters:
    name: "Not English characters"
    regex: '([А-я]+)'
    match_kinds:
      - identifier
      - parameter
    message: "Use English characters in identifiers or parameters"
    severity: error

line_length: 120

type_body_length:
  warning: 400
  error: 600

file_length:
  warning: 500
  error: 1200
  ignore_comment_only_lines: true

type_name:
  min_length: 3 # only warning
  max_length: # warning and error
    warning: 40
    error: 50
  excluded: iPhone # excluded via string
  allowed_symbols: ["_"] # these are allowed in type names

identifier_name:
  min_length: # only min_length
    error: 2 # only error
  excluded: # excluded via string array
    - x
    - y
    - z
    - id

nesting:
  type_level: 4

warning_threshold: 20

reporter: "xcode"
1

There are 1 answers

1
Joakim Danielson On BEST ANSWER

SwiftLint will not generate any warning in Xcode if you run it with the --fix argument.

The recommended way in the documentation to handle this is to run SwiftLint twice

swiftlint --fix && swiftlint

Then the second run will generate the warnings in Xcode for you.