Skip to content

New rule: If expressions should not be too complex #456

Description

@fourls

Prerequisites

  • This rule has not already been suggested.
  • This should be a new rule, not an improvement to an existing rule.
  • This rule would be generally useful, not specific to my code or setup.

Suggested rule title

If expressions should not be too complex

Rule description

Similar to the existing RoutineNestingDepth and TooManyNestedRoutines rules, this rule would catch if expressions that are unclear due to their size. This could be measured in a few ways, e.g.:

  • Sum length of the guard, then, or else expressions
  • Number of lines the entire expression covers
  • Number of nested if expressions
  • Whether anonymous methods are present
  • etc.

Rationale

Keeping ternary use limited makes code more readable and less prone to errors.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestruleImprovements or additions to rules

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions