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

function_body_length error value in configuration file not detected if no warning provided #4645

Closed
2 tasks done
gchiacchio opened this issue Dec 14, 2022 · 1 comment · Fixed by #4647
Closed
2 tasks done
Assignees
Labels
bug Unexpected and reproducible misbehavior.

Comments

@gchiacchio
Copy link

gchiacchio commented Dec 14, 2022

New Issue Checklist

Describe the bug

A clear and concise description of what the bug is.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint

Environment

  • SwiftLint version (run swiftlint version to be sure)?
swiftlint --version
0.50.3
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    Homebrew

  • Paste your configuration file:

# insert yaml contents here
function_body_length:
    error: 4
  • Are you using nested configurations?
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)?
Xcode 13.3.1
Build version 13E500a
  • 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.

THIS IS NOT TRIGGERING function_body_length (IT SHOULD)

echo "// Test
func test() {
    print("1")
    print("2")
    print("3")
    print("4")
    print("5")
}
" | swiftlint lint --no-cache --use-stdin

<nopath>:9:1: error: Trailing Newline Violation: Files should have a single trailing newline. (trailing_newline)
Done linting! Found 1 violation, 1 serious in 1 file.

NOW IF I ADD A warning LINE, IT WORKS

# insert yaml contents here
function_body_length:
    warning: 4
    error: 4
echo "// Test
func test() {
    print("1")
    print("2")
    print("3")
    print("4")
    print("5")
}
" | swiftlint lint --no-cache --use-stdin

<nopath>:2:6: error: Function Body Length Violation: Function body should span 4 lines or less excluding comments and whitespace: currently spans 5 lines (function_body_length)
<nopath>:9:1: error: Trailing Newline Violation: Files should have a single trailing newline. (trailing_newline)
Done linting! Found 2 violations, 2 serious in 1 file.
@gchiacchio
Copy link
Author

note it's also failing for other rules as type_body_length, haven't tested others yet

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