Skip to content
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

control_statement triggers on trailing closers requiring braces. #5135

Closed
2 tasks done
lhunath opened this issue Jul 19, 2023 · 0 comments · Fixed by #5141
Closed
2 tasks done

control_statement triggers on trailing closers requiring braces. #5135

lhunath opened this issue Jul 19, 2023 · 0 comments · Fixed by #5141
Assignees
Labels
bug Unexpected and reproducible misbehavior.

Comments

@lhunath
Copy link

lhunath commented Jul 19, 2023

New Issue Checklist

Describe the bug

SwiftLint rule control_statement triggers on statements that require braces due to usage of trailing closures.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint test.swift
Linting Swift files at paths test.swift
Linting 'test.swift' (1/1)
/Users/hubstaff/Developer/hubstaff/ios/test.swift:4:5: warning: Control Statement Violation: `if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses (control_statement)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version: 0.52.4
  • Installation method used: Homebrew
  • Xcode Version 15.0 beta 4 (15A5195m)
  • swift-driver version: 1.85 Apple Swift version 5.9 (swiftlang-5.9.0.120.7 clang-1500.0.34.3)
  • 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.
func foo() {
    var vm_info = task_vm_info()
    count = mach_msg_type_number_t(MemoryLayout<task_vm_info>.size) / 4
    if (withUnsafeMutablePointer(to: &vm_info) {
        $0.withMemoryRebound(to: task_info_t.self.Pointee, capacity: 1) {
            task_info(mach_task_self_, task_flavor_t(TASK_VM_INFO), $0, &count)
        }
    }) == KERN_SUCCESS {
        sample.memory_physical_used = vm_info.phys_footprint
    }
}
$ swiftlint lint --no-cache --use-stdin --enable-all-rules < test.swift
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>:5:9: warning: Anonymous Argument in Multiline Closure Violation: Use named arguments in multiline closures (anonymous_argument_in_multiline_closure)
<nopath>:6:69: warning: Anonymous Argument in Multiline Closure Violation: Use named arguments in multiline closures (anonymous_argument_in_multiline_closure)
<nopath>:4:5: warning: Control Statement Violation: `if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses (control_statement)
<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>:2:9: warning: Explicit Type Interface Violation: Properties should have a type interface (explicit_type_interface)
<nopath>:2:5: error: Identifier Name Violation: Variable name 'vm_info' should only contain alphanumeric and other allowed characters (identifier_name)
<nopath>:3:71: warning: No Magic Numbers Violation: Magic numbers should be replaced by named constants (no_magic_numbers)
Done linting! Found 8 violations, 1 serious in 1 file.
@SimplyDanny SimplyDanny added the bug Unexpected and reproducible misbehavior. label Jul 19, 2023
@SimplyDanny SimplyDanny self-assigned this Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants