Skip to content

no_magic_numbers doesnt work with tuple destructuring #5305

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

Closed
2 tasks done
laralove143 opened this issue Oct 28, 2023 · 1 comment · Fixed by #5327
Closed
2 tasks done

no_magic_numbers doesnt work with tuple destructuring #5305

laralove143 opened this issue Oct 28, 2023 · 1 comment · Fixed by #5327
Assignees
Labels
bug Unexpected and reproducible misbehavior. good first issue Issue to be taken up by new contributors yet unfamiliar with the project.

Comments

@laralove143
Copy link
Contributor

New Issue Checklist

Describe the bug

code like

let (httpStatusCodeErrorLowerBound, httpStatusCodeErrorUpperBound) = (400, 599)

still reports
No Magic Numbers Violation: Magic numbers should be replaced by named constants (no_magic_numbers)
while similar code

let httpStatusCodeErrorLowerBound = 400
let httpStatusCodeErrorUpperBound = 599

doesnt cause any lint violations

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Linting Swift files in current working directory
Linting 'Test.swift' (1/1)
Test.swift:2:75: warning: No Magic Numbers Violation: Magic numbers should be replaced by named constants (no_magic_numbers)
Test.swift:21:80: warning: No Magic Numbers Violation: Magic numbers should be replaced by named constants (no_magic_numbers)
Done linting! Found 2 violations, 0 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.53.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? SPM Plugin
  • Paste your configuration file:
disabled_rules:
  - force_try
  - trailing_comma

opt_in_rules:
  - accessibility_label_for_image
  - accessibility_trait_for_button
  - anonymous_argument_in_multiline_closure
  - array_init
  - attributes
  - balanced_xctest_lifecycle
  - closure_body_length
  - closure_end_indentation
  - closure_spacing
  - collection_alignment
  - comma_inheritance
  - conditional_returns_on_newline
  - contains_over_filter_count
  - contains_over_filter_is_empty
  - contains_over_first_not_nil
  - contains_over_range_nil_comparison
  - convenience_type
  - direct_return
  - discarded_notification_center_observer
  - discouraged_assert
  - discouraged_none_name
  - discouraged_object_literal
  - discouraged_optional_boolean
  - discouraged_optional_collection
  - empty_collection_literal
  - empty_count
  - empty_string
  - empty_xctest_method
  - enum_case_associated_values_count
  - expiring_todo
  - explicit_enum_raw_value
  - explicit_init
  - extension_access_modifier
  - fallthrough
  - fatal_error_message
  - file_header
  - file_name
  - file_name_no_space
  - file_types_order
  - first_where
  - flatmap_over_map_reduce
  - function_default_parameter_at_end
  - ibinspectable_in_extension
  - identical_operands
  - implicit_return
  - indentation_width
  - joined_default_parameter
  - last_where
  - legacy_multiple
  - legacy_objc_type
  - let_var_whitespace
  - literal_expression_end_indentation
  - local_doc_comment
  - lower_acl_than_parent
  - missing_docs
  - modifier_order
  - multiline_arguments
  - multiline_arguments_brackets
  - multiline_function_chains
  - multiline_literal_brackets
  - multiline_parameters
  - multiline_parameters_brackets
  - nimble_operator
  - no_extension_access_modifier
  - no_grouping_extension
  - no_magic_numbers
  - nslocalizedstring_key
  - nslocalizedstring_require_bundle
  - number_separator
  - object_literal
  - operator_usage_whitespace
#  for below swift 5.1
#  - optional_enum_case_matching
  - overridden_super_call
  - override_in_extension
  - pattern_matching_keywords
  - period_spacing
  - prefer_nimble
  - prefer_self_type_over_type_of_self
  - prefer_zero_over_explicit_init
  - prefixed_toplevel_constant
  - private_action
  - private_outlet
  - private_subject
#  on main branch only
#  - private_swiftui_state
  - prohibited_interface_builder
  - prohibited_super_call
  - quick_discouraged_call
  - quick_discouraged_focused_test
  - quick_discouraged_pending_test
  - raw_value_for_camel_cased_codable_enum
  - reduce_into
  - redundant_nil_coalescing
  - redundant_self_in_closure
  - redundant_type_annotation
  - required_enum_case
  - return_value_from_void_function
  - self_binding
  - shorthand_optional_binding
  - single_test_class
  - sorted_enum_cases
  - sorted_first_last
  - sorted_imports
  - static_operator
  - strict_fileprivate
  - strong_iboutlet
  - superfluous_else
  - switch_case_on_newline
  - test_case_accessibility
  - toggle_bool
  - trailing_closure
  - type_contents_order
  - unavailable_function
  - unhandled_throwing_task
  - unneeded_parentheses_in_closure_argument
  - unowned_variable_capture
  - untyped_error_in_catch
  - vertical_parameter_alignment_on_call
  - vertical_whitespace_between_cases
  - vertical_whitespace_closing_braces
  - vertical_whitespace_opening_braces
  - weak_delegate
  - xct_specific_matcher
  - yoda_condition

analyzer_rules:
  - capture_variable
  - typesafe_array_init
  - unused_declaration
  
missing_docs:
  excludes_inherited_types: false

allow_zero_lintable_files: false

reporter: "xcode"
  • Are you using nested configurations? no
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 15.0.1, Build version 15A507
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
$ echo "let (foo, bar) = (1, 2)" | swiftlint lint --no-cache --use-stdin --enable-all-rules
warning: The `inert_defer` rule is now deprecated and will be completely removed in a future release.
warning: The `unused_capture_list` rule is now deprecated and will be completely removed in a future release.
warning: The `anyobject_protocol` rule is now deprecated and will be completely removed in a future release.
<nopath>:1:1: warning: Explicit ACL Violation: All declarations should specify Access Control Level keywords explicitly (explicit_acl)
<nopath>:1:1: warning: Explicit ACL Violation: All declarations should specify Access Control Level keywords explicitly (explicit_acl)
<nopath>:1:1: warning: Explicit Top Level ACL Violation: Top-level declarations should specify Access Control Level keywords explicitly (explicit_top_level_acl)
<nopath>:1:5: warning: Explicit Type Interface Violation: Properties should have a type interface (explicit_type_interface)
<nopath>:1:71: warning: No Magic Numbers Violation: Magic numbers should be replaced by named constants (no_magic_numbers)
<nopath>:1:76: warning: No Magic Numbers Violation: Magic numbers should be replaced by named constants (no_magic_numbers)
Done linting! Found 6 violations, 0 serious in 1 file.
let (httpStatusCodeErrorLowerBound, httpStatusCodeErrorUpperBound) = (400, 599)
@SimplyDanny SimplyDanny added bug Unexpected and reproducible misbehavior. good first issue Issue to be taken up by new contributors yet unfamiliar with the project. labels Oct 29, 2023
@mildm8nnered
Copy link
Collaborator

I'm planning to take a look at this this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior. good first issue Issue to be taken up by new contributors yet unfamiliar with the project.
Projects
None yet
3 participants