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

✨ New Universal.FunctionDeclarations.NoLongClosures sniff #240

Merged
merged 1 commit into from
Jun 17, 2023

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
37 checks passed
@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