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

Unable to set type_body_length function_body_length file_length only as warnings with no error. #5822

Open
2 tasks done
uevs opened this issue Oct 10, 2024 · 1 comment
Open
2 tasks done
Labels
help Questions or user problems that require more explanation rather than code changes. repro-needed Issues that cannot be reproduced or miss proper descriptive examples.

Comments

@uevs
Copy link

uevs commented Oct 10, 2024

New Issue Checklist

Bug Description

I'm trying to set type_body_length function_body_length file_length to be warning only with custom length. I want to have a warning if the length reaches a certain limit, but no errors.

This is not clearly documented, but should be available #1647 #1691

I'm testing this by running:

swiftlint --quiet | grep -E 'error.*(type_body_length|function_body_length|file_length)'

And I would expect no errors in the output, but I do get errors using the default error limit of the respective rule.

I tried the following variations:

type_body_length: 400
type_body_length:
  warning: 400
type_body_length:
  - 400
type_body_length:
  warning: 400
  error: null
type_body_length:
  warning: 400
  error: nil
type_body_length:
  warning: 400
  error: ~

but none is working. It either gets the defults value of the rule:

error: Type Body Length Violation: Type body should span 500 lines or less excluding comments and whitespace: currently spans 528 lines (type_body_length)

or gives me:

warning: Invalid configuration for 'type_body_length' rule. Falling back to default.

Environment

  • SwiftLint version: 0.57.0
  • Xcode version: 16.0
  • Installation method used: Homebrew
  • Configuration file:
only_rules:
  - superfluous_disable_command
  - type_body_length
  - function_body_length
  - line_length
  - file_length
  # auto-correctable rules:
  - leading_whitespace
  - trailing_whitespace
  - trailing_comma
  - trailing_newline
  - colon
  - trailing_semicolon
  - opening_brace
  - closing_brace
  - return_arrow_whitespace
  - comma
  - empty_enum_arguments
  - empty_parameters
  - void_return

excluded:
  - fastlane/.tempbuild
  - Package/**/*/PreviewAssets.swift
  - Package/.build
type_body_length: 400
function_body_length: 91
file_length: 610
line_length:
  warning: 400
  error: 500
@SimplyDanny
Copy link
Collaborator

Can you provide a small reproducer? For me, this works. The configurations

type_body_length:
  warning: 40

type_body_length:
  warning: 40
  error: 50

type_body_length: 40

type_body_length: [40, 50]

work as I'd expect.

@SimplyDanny SimplyDanny added repro-needed Issues that cannot be reproduced or miss proper descriptive examples. help Questions or user problems that require more explanation rather than code changes. labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help Questions or user problems that require more explanation rather than code changes. repro-needed Issues that cannot be reproduced or miss proper descriptive examples.
Projects
None yet
Development

No branches or pull requests

2 participants