realm / realm/SwiftLint

Swiftlint hangs after processing all the files

Open
#4,215 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

New Issue Checklist
Describe the bug

I have written a custom rule to match constructors with more than 5 parameters.

custom_rules:
  constructor_parameters_count:
    included:
      - ".*\\.swift"
    name: "Constructor Parameters Count."
    regex: '^\s*(init\((\s*\w*\s*\w*\s*\:\s*\w*(\s*\=\s*(\w|\.|\(\))*)*,){5,}(\s*\w*\s*\w*\s*\:\s*\w*(\s*\=\s*(\w|\.|\(\))*)*)\))'
    capture_group: 1
    message: "Too many constructor arguments."

Swiftlint hangs after processing all the files.

Complete output when running SwiftLint, including the stack trace and command used
$ ../Pods/SwiftLint/swiftlint lint --strict --benchmark

hangs on

Linting 'TasksUITests.swift' (1591/1591)
Environment
  • SwiftLint version (run swiftlint version to be sure)? 0.49.1
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? CocoaPods
  • Paste your configuration file:
opt_in_rules:
  - array_init
  - closure_end_indentation
  - closure_parameter_position
  - closure_spacing
  - collection_alignment
  - contains_over_filter_count
  - contains_over_first_not_nil
  - convenience_type
  - discouraged_assert
  - discouraged_none_name
  - empty_collection_literal
  - empty_count
  - empty_string
  - explicit_init
  - fatal_error_message
  - first_where
  - flatmap_over_map_reduce
  - identical_operands
  - joined_default_parameter
  - last_where
  - legacy_multiple
  - legacy_random
  - literal_expression_end_indentation
  - modifier_order
  - number_separator
  - operator_usage_whitespace
  - overridden_super_call
  - prefer_self_type_over_type_of_self
  - private_action
  - private_outlet
  - prohibited_super_call
  - raw_value_for_camel_cased_codable_enum
  - reduce_into
  - redundant_nil_coalescing
  - required_enum_case
  - return_arrow_whitespace
  - sorted_first_last
  - statement_position
  - toggle_bool
  - unneeded_parentheses_in_closure_argument
  - unused_declaration
  - unused_import
  - vertical_parameter_alignment_on_call
  - vertical_whitespace_closing_braces
  - yoda_condition
  - custom_rules

disabled_rules:
  - block_based_kvo
  - cyclomatic_complexity
  - file_length
  - force_cast
  - function_body_length
  - large_tuple
  - line_length
  - nesting
  - identifier_name
  - force_try
  - function_parameter_count
  - type_body_length
  - multiple_closures_with_trailing_closure
  - type_name
  - closure_end_indentation
  - vertical_whitespace_opening_braces

excluded:
  - Carthage
  - Pods

trailing_whitespace:
  ignores_empty_lines: true

indentation: 2

custom_rules:
  constructor_parameters_count:
    included:
      - ".*\\.swift"
    name: "Constructor Parameters Count"
    regex: '^\s*(init\((\s*\w*\s*\w*\s*\:\s*\w*(\s*\=\s*(\w|\.|\(\))*)*,){5,}(\s*\w*\s*\w*\s*\:\s*\w*(\s*\=\s*(\w|\.|\(\))*)*)\))'
    capture_group: 1
    message: "Too many constructor arguments"

  • Are you using nested configurations? no
  • Which Xcode version are you using (check xcodebuild -version)?
    Xcode 13.4.1
    Build version 13F100
  • Do you have a sample that shows the issue? just the regex

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the hang with the supplied custom_rules configuration using ../Pods/SwiftLint/swiftlint lint --strict --benchmark, focusing on the custom constructor-parameter regex. Compare the run with that rule disabled, then trace custom-rule processing after the final file is reported. Done means linting completes instead of hanging and the configuration still reports the intended violations.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.