Skip to content

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jun 17, 2023

New sniff to check for "long" closures and recommend using named functions instead.

The sniff is fully configurable via the following properties:

  • (int) recommendedLines - this determines when a warning will be thrown. Defaults to 5, which means that a warning will be thrown if the closure is more than 5 lines long.
  • (int) maxLines - this determines when an error will be thrown. Defaults to 8, which means that an error will be thrown if the closure is more than 8 lines long.
  • (bool) ignoreCommentLines - whether or not comment-only lines should be ignored for the lines count. Defaults to true.
  • (bool) ignoreEmptyLines - whether or not blank lines should be ignored for the lines count. Defaults to true.

The error and the warning have their own error codes - ExceedsMaximum and ExceedsRecommended - and can be included/excluded separately from a ruleset.

Includes unit tests.
Includes documentation.
Includes metrics.

Closes #192

New sniff to check for "long" closures and recommend using named functions instead.

The sniff is fully configurable via the following properties:
* (int) `recommendedLines` - this determines when a warning will be thrown. Defaults to `5`, which means that a warning will be thrown if the closure is more than 5 lines long.
* (int) `maxLines` - this determines when an error will be thrown. Defaults to `8`, which means that an error will be thrown if the closure is more than 8 lines long.
* (bool) `ignoreCommentLines` - whether or not comment-only lines should be ignored for the lines count. Defaults to `true`.
* (bool) `ignoreEmptyLines` - whether or not blank lines should be ignored for the lines count. Defaults to `true`.

The error and the warning have their own error codes  - `ExceedsMaximum` and `ExceedsRecommended` - and can be included/excluded separately from a ruleset.

Includes unit tests.
Includes documentation.
Includes metrics.

Closes 192
@jrfnl jrfnl added this to the 1.1.0 milestone Jun 17, 2023
@jrfnl jrfnl merged commit 5bf5c3b into develop Jun 17, 2023
@jrfnl jrfnl deleted the feature/192-new-nolongclosures-sniff branch June 17, 2023 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sniff to discourage "long" closures
1 participant