cofiem/clearly-query

View on GitHub
lib/clearly/query/compose/conditions.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Module has too many lines. [132/100]
Open

      module Conditions
        include Clearly::Query::Compose::Comparison
        include Clearly::Query::Compose::Core
        include Clearly::Query::Compose::Range
        include Clearly::Query::Compose::Subset

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [28/10]
Open

        def condition_node_subset(operator, node, value)
          case operator
            when :range, :in_range
              compose_range_node(node, value)
            when :not_range, :not_in_range

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [24/10]
Open

        def condition_node_comparison(operator, node, value)
          case operator
            when :eq, :equal
              compose_eq_node(node, value)
            when :not_eq, :not_equal

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for condition_node_subset is too high. [13/6]
Open

        def condition_node_subset(operator, node, value)
          case operator
            when :range, :in_range
              compose_range_node(node, value)
            when :not_range, :not_in_range

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for condition_node_comparison is too high. [11/6]
Open

        def condition_node_comparison(operator, node, value)
          case operator
            when :eq, :equal
              compose_eq_node(node, value)
            when :not_eq, :not_equal

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method has too many lines. [11/10]
Open

        def condition_combine_new(combiner, conditions, new_condition)
          case combiner
            when :and
              conditions.nil? ? new_condition : compose_and(conditions, new_condition)
            when :or

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for condition_node_subset is too high. [16.97/15]
Open

        def condition_node_subset(operator, node, value)
          case operator
            when :range, :in_range
              compose_range_node(node, value)
            when :not_range, :not_in_range

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Cyclomatic complexity for condition_combine_new is too high. [7/6]
Open

        def condition_combine_new(combiner, conditions, new_condition)
          case combiner
            when :and
              conditions.nil? ? new_condition : compose_and(conditions, new_condition)
            when :or

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method condition_node_subset has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def condition_node_subset(operator, node, value)
          case operator
            when :range, :in_range
              compose_range_node(node, value)
            when :not_range, :not_in_range
Severity: Minor
Found in lib/clearly/query/compose/conditions.rb - About 1 hr to fix

    Method condition_combine_new has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def condition_combine_new(combiner, conditions, new_condition)
              case combiner
                when :and
                  conditions.nil? ? new_condition : compose_and(conditions, new_condition)
                when :or
    Severity: Minor
    Found in lib/clearly/query/compose/conditions.rb - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method condition_components has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def condition_components(operator, table, column_name, valid_fields, value)
    Severity: Minor
    Found in lib/clearly/query/compose/conditions.rb - About 35 mins to fix

      Indent when as deep as case.
      Open

                  when :or

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_lteq, :not_less_than_or_equal

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_in, :is_not_in

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :regex, :regex_match, :matches

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Use 2 spaces for indentation in an array, relative to the start of the line where the left square bracket is.
      Open

                  :regex, :regex_match, :matches,

      This cop checks the indentation of the first element in an array literal where the opening bracket and the first element are on separate lines. The other elements' indentations are handled by the AlignArray cop.

      By default, array literals that are arguments in a method call with parentheses, and where the opening square bracket of the array is on the same line as the opening parenthesis of the method call, shall have their first element indented one step (two spaces) more than the position inside the opening parenthesis.

      Other array literals shall have their first element indented one step more than the start of the line where the opening square bracket is.

      This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_brackets'. Here are examples:

      Example: EnforcedStyle: specialinsideparentheses (default)

      # The `special_inside_parentheses` style enforces that the first
      # element in an array literal where the opening bracket and first
      # element are on seprate lines is indented one step (two spaces) more
      # than the position inside the opening parenthesis.
      
      #bad
      array = [
        :value
      ]
      and_in_a_method_call([
        :no_difference
                           ])
      
      #good
      array = [
        :value
      ]
      but_in_a_method_call([
                             :its_like_this
                           ])

      Example: EnforcedStyle: consistent

      # The `consistent` style enforces that the first element in an array
      # literal where the opening bracket and the first element are on
      # seprate lines is indented the same as an array literal which is not
      # defined inside a method call.
      
      #bad
      # consistent
      array = [
        :value
      ]
      but_in_a_method_call([
                             :its_like_this
      ])
      
      #good
      array = [
        :value
      ]
      and_in_a_method_call([
        :no_difference
      ])

      Example: EnforcedStyle: align_brackets

      # The `align_brackets` style enforces that the opening and closing
      # brackets are indented to the same position.
      
      #bad
      # align_brackets
      and_now_for_something = [
                                :completely_different
      ]
      
      #good
      # align_brackets
      and_now_for_something = [
                                :completely_different
                              ]

      Indent when as deep as case.
      Open

                  when :lt, :less_than

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :gt, :greater_than

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_ends_with, :not_end_with, :does_not_end_with

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Use 2 (not 1) spaces for indentation.
      Open

                   conditions.nil? ? new_condition : compose_or(conditions, new_condition)

      This cops checks for indentation that doesn't use the specified number of spaces.

      See also the IndentationConsistency cop which is the companion to this one.

      Example:

      # bad
      class A
       def test
        puts 'hello'
       end
      end
      
      # good
      class A
        def test
          puts 'hello'
        end
      end

      Example: IgnoredPatterns: ['^\s*module']

      # bad
      module A
      class B
        def test
        puts 'hello'
        end
      end
      end
      
      # good
      module A
      class B
        def test
          puts 'hello'
        end
      end
      end

      Indent when as deep as case.
      Open

                  when :in, :is_in

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_gteq, :not_greater_than_or_equal

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Use 2 spaces for indentation in an array, relative to the start of the line where the left square bracket is.
      Open

                  :range, :in_range,

      This cop checks the indentation of the first element in an array literal where the opening bracket and the first element are on separate lines. The other elements' indentations are handled by the AlignArray cop.

      By default, array literals that are arguments in a method call with parentheses, and where the opening square bracket of the array is on the same line as the opening parenthesis of the method call, shall have their first element indented one step (two spaces) more than the position inside the opening parenthesis.

      Other array literals shall have their first element indented one step more than the start of the line where the opening square bracket is.

      This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_brackets'. Here are examples:

      Example: EnforcedStyle: specialinsideparentheses (default)

      # The `special_inside_parentheses` style enforces that the first
      # element in an array literal where the opening bracket and first
      # element are on seprate lines is indented one step (two spaces) more
      # than the position inside the opening parenthesis.
      
      #bad
      array = [
        :value
      ]
      and_in_a_method_call([
        :no_difference
                           ])
      
      #good
      array = [
        :value
      ]
      but_in_a_method_call([
                             :its_like_this
                           ])

      Example: EnforcedStyle: consistent

      # The `consistent` style enforces that the first element in an array
      # literal where the opening bracket and the first element are on
      # seprate lines is indented the same as an array literal which is not
      # defined inside a method call.
      
      #bad
      # consistent
      array = [
        :value
      ]
      but_in_a_method_call([
                             :its_like_this
      ])
      
      #good
      array = [
        :value
      ]
      and_in_a_method_call([
        :no_difference
      ])

      Example: EnforcedStyle: align_brackets

      # The `align_brackets` style enforces that the opening and closing
      # brackets are indented to the same position.
      
      #bad
      # align_brackets
      and_now_for_something = [
                                :completely_different
      ]
      
      #good
      # align_brackets
      and_now_for_something = [
                                :completely_different
                              ]

      Indent when as deep as case.
      Open

                  when :and

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Extra blank line detected.
      Open

      
              # Build a condition.

      This cops checks for two or more consecutive blank lines.

      Example:

      # bad - It has two empty lines.
      some_method
      # one empty line
      # two empty lines
      some_method
      
      # good
      some_method
      # one empty line
      some_method

      Indent when as deep as case.
      Open

                  when :not_contains, :not_contain, :does_not_contain

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Extra empty line detected at module body beginning.
      Open

      
            # Methods for building conditions.

      This cops checks if empty lines around the bodies of modules match the configuration.

      Example: EnforcedStyle: empty_lines

      # good
      
      module Foo
      
        def bar
          # ...
        end
      
      end

      Example: EnforcedStyle: emptylinesexcept_namespace

      # good
      
      module Foo
        module Bar
      
          # ...
      
        end
      end

      Example: EnforcedStyle: emptylinesspecial

      # good
      module Foo
      
        def bar; end
      
      end

      Example: EnforcedStyle: noemptylines (default)

      # good
      
      module Foo
        def bar
          # ...
        end
      end

      Indent when as deep as case.
      Open

                  when :eq, :equal

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_gt, :not_greater_than

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :lteq, :less_than_or_equal

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :contains, :contain

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_starts_with, :not_start_with, :does_not_start_with

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_regex, :not_regex_match, :does_not_match, :not_match

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent the first line of the right-hand-side of a multi-line assignment.
      Open

                  OPERATORS_COMPARISON +
                      OPERATORS_RANGE +
                      OPERATORS_SUBSET +
                      OPERATORS_REGEX +
                      OPERATORS_SPECIAL

      This cop checks the indentation of the first line of the right-hand-side of a multi-line assignment.

      Example:

      # bad
      value =
      if foo
        'bar'
      end
      
      # good
      value =
        if foo
          'bar'
        end

      The indentation of the remaining lines can be corrected with other cops such as IndentationConsistency and EndAlignment.

      Indent when as deep as case.
      Open

                  when :gteq, :greater_than_or_equal

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Use 2 spaces for indentation in an array, relative to the start of the line where the left square bracket is.
      Open

                  :eq, :equal,

      This cop checks the indentation of the first element in an array literal where the opening bracket and the first element are on separate lines. The other elements' indentations are handled by the AlignArray cop.

      By default, array literals that are arguments in a method call with parentheses, and where the opening square bracket of the array is on the same line as the opening parenthesis of the method call, shall have their first element indented one step (two spaces) more than the position inside the opening parenthesis.

      Other array literals shall have their first element indented one step more than the start of the line where the opening square bracket is.

      This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_brackets'. Here are examples:

      Example: EnforcedStyle: specialinsideparentheses (default)

      # The `special_inside_parentheses` style enforces that the first
      # element in an array literal where the opening bracket and first
      # element are on seprate lines is indented one step (two spaces) more
      # than the position inside the opening parenthesis.
      
      #bad
      array = [
        :value
      ]
      and_in_a_method_call([
        :no_difference
                           ])
      
      #good
      array = [
        :value
      ]
      but_in_a_method_call([
                             :its_like_this
                           ])

      Example: EnforcedStyle: consistent

      # The `consistent` style enforces that the first element in an array
      # literal where the opening bracket and the first element are on
      # seprate lines is indented the same as an array literal which is not
      # defined inside a method call.
      
      #bad
      # consistent
      array = [
        :value
      ]
      but_in_a_method_call([
                             :its_like_this
      ])
      
      #good
      array = [
        :value
      ]
      and_in_a_method_call([
        :no_difference
      ])

      Example: EnforcedStyle: align_brackets

      # The `align_brackets` style enforces that the opening and closing
      # brackets are indented to the same position.
      
      #bad
      # align_brackets
      and_now_for_something = [
                                :completely_different
      ]
      
      #good
      # align_brackets
      and_now_for_something = [
                                :completely_different
                              ]

      Extra empty line detected at module body end.
      Open

      
            end

      This cops checks if empty lines around the bodies of modules match the configuration.

      Example: EnforcedStyle: empty_lines

      # good
      
      module Foo
      
        def bar
          # ...
        end
      
      end

      Example: EnforcedStyle: emptylinesexcept_namespace

      # good
      
      module Foo
        module Bar
      
          # ...
      
        end
      end

      Example: EnforcedStyle: emptylinesspecial

      # good
      module Foo
      
        def bar; end
      
      end

      Example: EnforcedStyle: noemptylines (default)

      # good
      
      module Foo
        def bar
          # ...
        end
      end

      Indent when as deep as case.
      Open

                  when :not

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_eq, :not_equal

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :starts_with, :start_with

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Use empty lines between method definitions.
      Open

              def condition_components(operator, table, column_name, valid_fields, value)

      This cop checks whether method definitions are separated by one empty line.

      NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

      AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

      Example:

      # bad
      def a
      end
      def b
      end

      Example:

      # good
      def a
      end
      
      def b
      end

      Use 2 spaces for indentation in an array, relative to the start of the line where the left square bracket is.
      Open

                  :in, :is_in,

      This cop checks the indentation of the first element in an array literal where the opening bracket and the first element are on separate lines. The other elements' indentations are handled by the AlignArray cop.

      By default, array literals that are arguments in a method call with parentheses, and where the opening square bracket of the array is on the same line as the opening parenthesis of the method call, shall have their first element indented one step (two spaces) more than the position inside the opening parenthesis.

      Other array literals shall have their first element indented one step more than the start of the line where the opening square bracket is.

      This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_brackets'. Here are examples:

      Example: EnforcedStyle: specialinsideparentheses (default)

      # The `special_inside_parentheses` style enforces that the first
      # element in an array literal where the opening bracket and first
      # element are on seprate lines is indented one step (two spaces) more
      # than the position inside the opening parenthesis.
      
      #bad
      array = [
        :value
      ]
      and_in_a_method_call([
        :no_difference
                           ])
      
      #good
      array = [
        :value
      ]
      but_in_a_method_call([
                             :its_like_this
                           ])

      Example: EnforcedStyle: consistent

      # The `consistent` style enforces that the first element in an array
      # literal where the opening bracket and the first element are on
      # seprate lines is indented the same as an array literal which is not
      # defined inside a method call.
      
      #bad
      # consistent
      array = [
        :value
      ]
      but_in_a_method_call([
                             :its_like_this
      ])
      
      #good
      array = [
        :value
      ]
      and_in_a_method_call([
        :no_difference
      ])

      Example: EnforcedStyle: align_brackets

      # The `align_brackets` style enforces that the opening and closing
      # brackets are indented to the same position.
      
      #bad
      # align_brackets
      and_now_for_something = [
                                :completely_different
      ]
      
      #good
      # align_brackets
      and_now_for_something = [
                                :completely_different
                              ]

      Indent when as deep as case.
      Open

                  when :range, :in_range

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_range, :not_in_range

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :not_lt, :not_less_than

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Indent when as deep as case.
      Open

                  when :ends_with, :end_with

      This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

      It will register a separate offense for each misaligned when.

      Example:

      # If Layout/EndAlignment is set to keyword style (default)
      # *case* and *end* should always be aligned to same depth,
      # and therefore *when* should always be aligned to both -
      # regardless of configuration.
      
      # bad for all styles
      case n
        when 0
          x * 2
        else
          y / 3
      end
      
      # good for all styles
      case n
      when 0
        x * 2
      else
        y / 3
      end

      Example: EnforcedStyle: case (default)

      # if EndAlignment is set to other style such as
      # start_of_line (as shown below), then *when* alignment
      # configuration does have an effect.
      
      # bad
      a = case n
      when 0
        x * 2
      else
        y / 3
      end
      
      # good
      a = case n
          when 0
            x * 2
          else
            y / 3
      end

      Example: EnforcedStyle: end

      # bad
      a = case n
          when 0
            x * 2
          else
            y / 3
      end
      
      # good
      a = case n
      when 0
        x * 2
      else
        y / 3
      end

      Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
      Open

                  :not_ends_with, :not_end_with, :does_not_end_with]

      This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

      When using the symmetrical (default) style:

      If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

      If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

      When using the new_line style:

      The closing brace of a multi-line array literal must be on the line after the last element of the array.

      When using the same_line style:

      The closing brace of a multi-line array literal must be on the same line as the last element of the array.

      Example: EnforcedStyle: symmetrical (default)

      # bad
        [ :a,
          :b
        ]
      
        # bad
        [
          :a,
          :b ]
      
        # good
        [ :a,
          :b ]
      
        # good
        [
          :a,
          :b
        ]

      Example: EnforcedStyle: new_line

      # bad
        [
          :a,
          :b ]
      
        # bad
        [ :a,
          :b ]
      
        # good
        [ :a,
          :b
        ]
      
        # good
        [
          :a,
          :b
        ]

      Example: EnforcedStyle: same_line

      # bad
        [ :a,
          :b
        ]
      
        # bad
        [
          :a,
          :b
        ]
      
        # good
        [
          :a,
          :b ]
      
        # good
        [ :a,
          :b ]

      Align the operands of an expression in an assignment spanning multiple lines.
      Open

                      OPERATORS_REGEX +

      This cop checks the indentation of the right hand side operand in binary operations that span more than one line.

      Example:

      # bad
      if a +
      b
        something
      end
      
      # good
      if a +
         b
        something
      end

      Freeze mutable objects assigned to constants.
      Open

              OPERATORS_LOGICAL = [:and, :or, :not]

      This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

      Example:

      # bad
      CONST = [1, 2, 3]
      
      # good
      CONST = [1, 2, 3].freeze

      Provide an exception class and message as arguments to fail.
      Open

                fail Clearly::Query::QueryArgumentError.new("unrecognised operator '#{operator}'") if new_condition.nil?

      This cop checks the args passed to fail and raise. For exploded style (default), it recommends passing the exception class and message to raise, rather than construct an instance of the error. It will still allow passing just a message, or the construction of an error with more than one argument.

      The exploded style works identically, but with the addition that it will also suggest constructing error objects when the exception is passed multiple arguments.

      Example: EnforcedStyle: exploded (default)

      # bad
      raise StandardError.new("message")
      
      # good
      raise StandardError, "message"
      fail "message"
      raise MyCustomError.new(arg1, arg2, arg3)
      raise MyKwArgError.new(key1: val1, key2: val2)

      Example: EnforcedStyle: compact

      # bad
      raise StandardError, "message"
      raise RuntimeError, arg1, arg2, arg3
      
      # good
      raise StandardError.new("message")
      raise MyCustomError.new(arg1, arg2, arg3)
      fail "message"

      Always use raise to signal exceptions.
      Open

                fail Clearly::Query::QueryArgumentError.new("unrecognised operator '#{operator}'") if new_condition.nil?

      This cop checks for uses of fail and raise.

      Example: EnforcedStyle: only_raise (default)

      # The `only_raise` style enforces the sole use of `raise`.
      # bad
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail
      
      # good
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise

      Example: EnforcedStyle: only_fail

      # The `only_fail` style enforces the sole use of `fail`.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail

      Example: EnforcedStyle: semantic

      # The `semantic` style enforces the use of `fail` to signal an
      # exception, then will use `raise` to trigger an offense after
      # it has been rescued.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        # Error thrown
      rescue Exception
        fail
      end
      
      Kernel.fail
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        raise 'Preferably with descriptive message'
      end
      
      explicit_receiver.fail
      explicit_receiver.raise

      Line is too long. [83/80]
      Open

              def condition_components(operator, table, column_name, valid_fields, value)

      Freeze mutable objects assigned to constants.
      Open

              OPERATORS_COMPARISON = [
                  :eq, :equal,
                  :not_eq, :not_equal,
                  :lt, :less_than,
                  :not_lt, :not_less_than,

      This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

      Example:

      # bad
      CONST = [1, 2, 3]
      
      # good
      CONST = [1, 2, 3].freeze

      Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
      Open

                  :not_range, :not_in_range]

      This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

      When using the symmetrical (default) style:

      If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

      If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

      When using the new_line style:

      The closing brace of a multi-line array literal must be on the line after the last element of the array.

      When using the same_line style:

      The closing brace of a multi-line array literal must be on the same line as the last element of the array.

      Example: EnforcedStyle: symmetrical (default)

      # bad
        [ :a,
          :b
        ]
      
        # bad
        [
          :a,
          :b ]
      
        # good
        [ :a,
          :b ]
      
        # good
        [
          :a,
          :b
        ]

      Example: EnforcedStyle: new_line

      # bad
        [
          :a,
          :b ]
      
        # bad
        [ :a,
          :b ]
      
        # good
        [ :a,
          :b
        ]
      
        # good
        [
          :a,
          :b
        ]

      Example: EnforcedStyle: same_line

      # bad
        [ :a,
          :b
        ]
      
        # bad
        [
          :a,
          :b
        ]
      
        # good
        [
          :a,
          :b ]
      
        # good
        [ :a,
          :b ]

      Align the operands of an expression in an assignment spanning multiple lines.
      Open

                      OPERATORS_SPECIAL

      This cop checks the indentation of the right hand side operand in binary operations that span more than one line.

      Example:

      # bad
      if a +
      b
        something
      end
      
      # good
      if a +
         b
        something
      end

      Line is too long. [86/80]
      Open

                    conditions.nil? ? not_condition : compose_and(conditions, not_condition)

      Freeze mutable objects assigned to constants.
      Open

              OPERATORS_SPECIAL = [:null, :is_null]

      This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

      Example:

      # bad
      CONST = [1, 2, 3]
      
      # good
      CONST = [1, 2, 3].freeze

      Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
      Open

                  :not_gteq, :not_greater_than_or_equal]

      This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

      When using the symmetrical (default) style:

      If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

      If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

      When using the new_line style:

      The closing brace of a multi-line array literal must be on the line after the last element of the array.

      When using the same_line style:

      The closing brace of a multi-line array literal must be on the same line as the last element of the array.

      Example: EnforcedStyle: symmetrical (default)

      # bad
        [ :a,
          :b
        ]
      
        # bad
        [
          :a,
          :b ]
      
        # good
        [ :a,
          :b ]
      
        # good
        [
          :a,
          :b
        ]

      Example: EnforcedStyle: new_line

      # bad
        [
          :a,
          :b ]
      
        # bad
        [ :a,
          :b ]
      
        # good
        [ :a,
          :b
        ]
      
        # good
        [
          :a,
          :b
        ]

      Example: EnforcedStyle: same_line

      # bad
        [ :a,
          :b
        ]
      
        # bad
        [
          :a,
          :b
        ]
      
        # good
        [
          :a,
          :b ]
      
        # good
        [ :a,
          :b ]

      Align the operands of an expression in an assignment spanning multiple lines.
      Open

                      OPERATORS_SUBSET +

      This cop checks the indentation of the right hand side operand in binary operations that span more than one line.

      Example:

      # bad
      if a +
      b
        something
      end
      
      # good
      if a +
         b
        something
      end

      Final newline missing.
      Open

      end

      Line is too long. [114/80]
      Open

                fail Clearly::Query::QueryArgumentError.new("unrecognised operator '#{operator}'") if new_condition.nil?

      Use %i or %I for an array of symbols.
      Open

              OPERATORS_SUBSET = [
                  :in, :is_in,
                  :not_in, :is_not_in,
                  :contains, :contain,
                  :not_contains, :not_contain, :does_not_contain,

      This cop can check for array literals made up of symbols that are not using the %i() syntax.

      Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %i[foo bar baz]
      
      # bad
      [:foo, :bar, :baz]

      Example: EnforcedStyle: brackets

      # good
      [:foo, :bar, :baz]
      
      # bad
      %i[foo bar baz]

      Always use raise to signal exceptions.
      Open

                    fail Clearly::Query::QueryArgumentError.new("unrecognised logical operator '#{combiner}'")

      This cop checks for uses of fail and raise.

      Example: EnforcedStyle: only_raise (default)

      # The `only_raise` style enforces the sole use of `raise`.
      # bad
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail
      
      # good
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise

      Example: EnforcedStyle: only_fail

      # The `only_fail` style enforces the sole use of `fail`.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail

      Example: EnforcedStyle: semantic

      # The `semantic` style enforces the use of `fail` to signal an
      # exception, then will use `raise` to trigger an offense after
      # it has been rescued.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        # Error thrown
      rescue Exception
        fail
      end
      
      Kernel.fail
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        raise 'Preferably with descriptive message'
      end
      
      explicit_receiver.fail
      explicit_receiver.raise

      Use %i or %I for an array of symbols.
      Open

              OPERATORS_SPECIAL = [:null, :is_null]

      This cop can check for array literals made up of symbols that are not using the %i() syntax.

      Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %i[foo bar baz]
      
      # bad
      [:foo, :bar, :baz]

      Example: EnforcedStyle: brackets

      # good
      [:foo, :bar, :baz]
      
      # bad
      %i[foo bar baz]

      Line is too long. [86/80]
      Open

                    conditions.nil? ? new_condition : compose_and(conditions, new_condition)

      Redundant else-clause.
      Open

                  else

      Checks for empty else-clauses, possibly including comments and/or an explicit nil depending on the EnforcedStyle.

      Example: EnforcedStyle: empty

      # warn only on empty else
      
      # bad
      if condition
        statement
      else
      end
      
      # good
      if condition
        statement
      else
        nil
      end
      
      # good
      if condition
        statement
      else
        statement
      end
      
      # good
      if condition
        statement
      end

      Example: EnforcedStyle: nil

      # warn on else with nil in it
      
      # bad
      if condition
        statement
      else
        nil
      end
      
      # good
      if condition
        statement
      else
      end
      
      # good
      if condition
        statement
      else
        statement
      end
      
      # good
      if condition
        statement
      end

      Example: EnforcedStyle: both (default)

      # warn on empty else and else with nil in it
      
      # bad
      if condition
        statement
      else
        nil
      end
      
      # bad
      if condition
        statement
      else
      end
      
      # good
      if condition
        statement
      else
        statement
      end
      
      # good
      if condition
        statement
      end

      Align the operands of an expression in an assignment spanning multiple lines.
      Open

                      OPERATORS_RANGE +

      This cop checks the indentation of the right hand side operand in binary operations that span more than one line.

      Example:

      # bad
      if a +
      b
        something
      end
      
      # good
      if a +
         b
        something
      end

      Line is too long. [97/80]
      Open

                  combined_conditions = condition_combine_new(combiner, combined_conditions, condition)

      Line is too long. [92/80]
      Open

                new_condition = condition_node_subset(operator, node, value) if new_condition.nil?

      Use %i or %I for an array of symbols.
      Open

              OPERATORS_COMPARISON = [
                  :eq, :equal,
                  :not_eq, :not_equal,
                  :lt, :less_than,
                  :not_lt, :not_less_than,

      This cop can check for array literals made up of symbols that are not using the %i() syntax.

      Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %i[foo bar baz]
      
      # bad
      [:foo, :bar, :baz]

      Example: EnforcedStyle: brackets

      # good
      [:foo, :bar, :baz]
      
      # bad
      %i[foo bar baz]

      Line is too long. [104/80]
      Open

                    fail Clearly::Query::QueryArgumentError.new("unrecognised logical operator '#{combiner}'")

      Freeze mutable objects assigned to constants.
      Open

              OPERATORS_REGEX = [
                  :regex, :regex_match, :matches,
                  :not_regex, :not_regex_match, :does_not_match, :not_match]

      This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

      Example:

      # bad
      CONST = [1, 2, 3]
      
      # good
      CONST = [1, 2, 3].freeze

      Provide an exception class and message as arguments to fail.
      Open

                    fail Clearly::Query::QueryArgumentError.new("unrecognised logical operator '#{combiner}'")

      This cop checks the args passed to fail and raise. For exploded style (default), it recommends passing the exception class and message to raise, rather than construct an instance of the error. It will still allow passing just a message, or the construction of an error with more than one argument.

      The exploded style works identically, but with the addition that it will also suggest constructing error objects when the exception is passed multiple arguments.

      Example: EnforcedStyle: exploded (default)

      # bad
      raise StandardError.new("message")
      
      # good
      raise StandardError, "message"
      fail "message"
      raise MyCustomError.new(arg1, arg2, arg3)
      raise MyKwArgError.new(key1: val1, key2: val2)

      Example: EnforcedStyle: compact

      # bad
      raise StandardError, "message"
      raise RuntimeError, arg1, arg2, arg3
      
      # good
      raise StandardError.new("message")
      raise MyCustomError.new(arg1, arg2, arg3)
      fail "message"

      Line is too long. [84/80]
      Open

                   conditions.nil? ? new_condition : compose_or(conditions, new_condition)

      Freeze mutable objects assigned to constants.
      Open

              OPERATORS_RANGE = [
                  :range, :in_range,
                  :not_range, :not_in_range]

      This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

      Example:

      # bad
      CONST = [1, 2, 3]
      
      # good
      CONST = [1, 2, 3].freeze

      Redundant else-clause.
      Open

                  else

      Checks for empty else-clauses, possibly including comments and/or an explicit nil depending on the EnforcedStyle.

      Example: EnforcedStyle: empty

      # warn only on empty else
      
      # bad
      if condition
        statement
      else
      end
      
      # good
      if condition
        statement
      else
        nil
      end
      
      # good
      if condition
        statement
      else
        statement
      end
      
      # good
      if condition
        statement
      end

      Example: EnforcedStyle: nil

      # warn on else with nil in it
      
      # bad
      if condition
        statement
      else
        nil
      end
      
      # good
      if condition
        statement
      else
      end
      
      # good
      if condition
        statement
      else
        statement
      end
      
      # good
      if condition
        statement
      end

      Example: EnforcedStyle: both (default)

      # warn on empty else and else with nil in it
      
      # bad
      if condition
        statement
      else
        nil
      end
      
      # bad
      if condition
        statement
      else
      end
      
      # good
      if condition
        statement
      else
        statement
      end
      
      # good
      if condition
        statement
      end

      Freeze mutable objects assigned to constants.
      Open

              OPERATORS_SUBSET = [
                  :in, :is_in,
                  :not_in, :is_not_in,
                  :contains, :contain,
                  :not_contains, :not_contain, :does_not_contain,

      This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

      Example:

      # bad
      CONST = [1, 2, 3]
      
      # good
      CONST = [1, 2, 3].freeze

      Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.
      Open

                  :not_regex, :not_regex_match, :does_not_match, :not_match]

      This cop checks that the closing brace in an array literal is either on the same line as the last array element, or a new line.

      When using the symmetrical (default) style:

      If an array's opening brace is on the same line as the first element of the array, then the closing brace should be on the same line as the last element of the array.

      If an array's opening brace is on the line above the first element of the array, then the closing brace should be on the line below the last element of the array.

      When using the new_line style:

      The closing brace of a multi-line array literal must be on the line after the last element of the array.

      When using the same_line style:

      The closing brace of a multi-line array literal must be on the same line as the last element of the array.

      Example: EnforcedStyle: symmetrical (default)

      # bad
        [ :a,
          :b
        ]
      
        # bad
        [
          :a,
          :b ]
      
        # good
        [ :a,
          :b ]
      
        # good
        [
          :a,
          :b
        ]

      Example: EnforcedStyle: new_line

      # bad
        [
          :a,
          :b ]
      
        # bad
        [ :a,
          :b ]
      
        # good
        [ :a,
          :b
        ]
      
        # good
        [
          :a,
          :b
        ]

      Example: EnforcedStyle: same_line

      # bad
        [ :a,
          :b
        ]
      
        # bad
        [
          :a,
          :b
        ]
      
        # good
        [
          :a,
          :b ]
      
        # good
        [ :a,
          :b ]

      Use %i or %I for an array of symbols.
      Open

              OPERATORS_RANGE = [
                  :range, :in_range,
                  :not_range, :not_in_range]

      This cop can check for array literals made up of symbols that are not using the %i() syntax.

      Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %i[foo bar baz]
      
      # bad
      [:foo, :bar, :baz]

      Example: EnforcedStyle: brackets

      # good
      [:foo, :bar, :baz]
      
      # bad
      %i[foo bar baz]

      Use %i or %I for an array of symbols.
      Open

              OPERATORS_REGEX = [
                  :regex, :regex_match, :matches,
                  :not_regex, :not_regex_match, :does_not_match, :not_match]

      This cop can check for array literals made up of symbols that are not using the %i() syntax.

      Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %i[foo bar baz]
      
      # bad
      [:foo, :bar, :baz]

      Example: EnforcedStyle: brackets

      # good
      [:foo, :bar, :baz]
      
      # bad
      %i[foo bar baz]

      Use %i or %I for an array of symbols.
      Open

                new_condition = compose_null_node(node, value) if new_condition.nil? && [:null, :is_null].include?(operator)

      This cop can check for array literals made up of symbols that are not using the %i() syntax.

      Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %i[foo bar baz]
      
      # bad
      [:foo, :bar, :baz]

      Example: EnforcedStyle: brackets

      # good
      [:foo, :bar, :baz]
      
      # bad
      %i[foo bar baz]

      Line is too long. [118/80]
      Open

                new_condition = compose_null_node(node, value) if new_condition.nil? && [:null, :is_null].include?(operator)

      Use %i or %I for an array of symbols.
      Open

              OPERATORS_LOGICAL = [:and, :or, :not]

      This cop can check for array literals made up of symbols that are not using the %i() syntax.

      Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %i[foo bar baz]
      
      # bad
      [:foo, :bar, :baz]

      Example: EnforcedStyle: brackets

      # good
      [:foo, :bar, :baz]
      
      # bad
      %i[foo bar baz]

      There are no issues that match your filters.

      Category
      Status