Skip to content

Regression: line_length does not report violations in strings with extended string delimiters with ignores_multiline_strings: true #6220

@Nef10

Description

@Nef10

New Issue Checklist

Bug Description

A clear and concise description of what the bug is. Ideally, provide a small (but compilable) example code snippet that
can be used to reproduce the issue.

// This does not triggers a violation:
let pattern = #"\s*.*?\.gif\s*(\d{4}.*?[a-z]\d)\sjjjdjdjdjddjdjj*$\s*[a-zA-z]*[ ]?(?:Contribution|Fund Transfer|Withdrawal)\s*([0-9.,]*)\s*units\s*@\s*\$([0-9.,]*)/unit\s*(-?[0-9.,]*)\s*$"#

Mention the command or other SwiftLint integration method that caused the issue. Include stack traces or command output.

$ swiftlint lint

Output:

Linting 'a.swift' (1/1)
Done linting! Found 0 violations, 0 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure): 0.60.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc): Homebrew
  • Configuration file:
# Updated for 0.57.0

excluded:
  - ".build"
  - "**/*pb.swift"

opt_in_rules:
  - attributes
  - closure_end_indentation
  - closure_spacing
  - conditional_returns_on_newline
  - empty_count
  - explicit_init
  - fatal_error_message
  - first_where
  - implicit_return
  - let_var_whitespace
  - multiline_parameters
  - nimble_operator
  - no_extension_access_modifier
  - number_separator
  - object_literal
  - operator_usage_whitespace
  - overridden_super_call
  - private_outlet
  - prohibited_super_call
  - redundant_nil_coalescing
  - sorted_imports
  - switch_case_on_newline
  - vertical_parameter_alignment_on_call
  - unneeded_parentheses_in_closure_argument
  - trailing_closure
  - joined_default_parameter
  - single_test_class
  - pattern_matching_keywords
  - contains_over_first_not_nil
  - array_init
  - multiline_arguments
  - literal_expression_end_indentation
  - strict_fileprivate
  - sorted_first_last
  - override_in_extension
  - private_action
  - yoda_condition
  - discouraged_optional_boolean
  - empty_string
  - untyped_error_in_catch
  - discouraged_optional_collection
  - fallthrough
  - modifier_order
  - unavailable_function
  - multiline_function_chains
  - redundant_set_access_control
  - empty_xctest_method
  - function_default_parameter_at_end
  - file_name
  - convenience_type
  - missing_docs
  - legacy_random
  - closure_body_length
  - toggle_bool
  - identical_operands
  - collection_alignment
  - multiline_literal_brackets
  - multiline_parameters_brackets
  - xct_specific_matcher
  - last_where
  - strong_iboutlet
  - reduce_into
  - file_types_order
  - type_contents_order
  - nslocalizedstring_require_bundle
  - unowned_variable_capture
  - legacy_multiple
  - contains_over_filter_count
  - contains_over_filter_is_empty
  - empty_collection_literal
  - contains_over_range_nil_comparison
  - flatmap_over_map_reduce
  - raw_value_for_camel_cased_codable_enum
  - enum_case_associated_values_count
  - optional_enum_case_matching
  - prefer_self_type_over_type_of_self
  - orphaned_doc_comment
  - prefer_zero_over_explicit_init
  - test_case_accessibility
  - discouraged_assert
  - legacy_objc_type
  - private_subject
  - discouraged_none_name
  - redundant_type_annotation
  - prefer_self_in_static_references
  - weak_delegate
  - return_value_from_void_function
  - accessibility_label_for_image
  - comma_inheritance
  - self_binding
  - accessibility_trait_for_button
  - shorthand_optional_binding
  - direct_return
  - period_spacing
  - superfluous_else
  - redundant_self_in_closure
  - unhandled_throwing_task
  - private_swiftui_state
  - final_test_case
  - prefer_key_path
  - no_empty_block
  - unused_parameter

disabled_rules:
  - trailing_comma

line_length:
  warning: 175
  ignores_multiline_strings: true
function_body_length: 30
identifier_name:
  max_length:
    warning: 45
type_name:
  max_length:
    warning: 45
number_separator:
  minimum_fraction_length: 3

When changing ignores_multiline_strings to false, it reports the line length violation:

a.swift:1:1: warning: Line Length Violation: Line should be 175 characters or less; currently it has 189 characters (line_length)
Done linting! Found 1 violation, 0 serious in 1 file.

This was working correctly in 0.59.1

Extended String Delimiters can be used to create multi-line strings as well, but in this case it is a single line string, so with ignores_multiline_strings it should not be ignored.

Metadata

Metadata

Assignees

Labels

bugUnexpected and reproducible misbehavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions