asafschers/scoruby

View on GitHub

Showing 12 of 12 total issues

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

        def score(features)
          decisions_count = decisions_count(features)

          if regression?
            {

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 score is too high. [16.16/15]
Open

        def score(features)
          decisions_count = decisions_count(features)

          if regression?
            {

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

Avoid too many return statements within this method.
Open

      return Models::LogisticRegression::Model.new(xml) if logistic_regression?(xml)
Severity: Major
Found in lib/scoruby/model_factory.rb - About 30 mins to fix

    Space missing inside }.
    Open

              @xml.xpath(COEFFICIENTS_VALUES_PATH).map{|attribute| attribute.value.to_f}

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Line is too long. [90/80]
    Open

            COEFFICIENTS_VALUES_PATH = '//PMML/GeneralRegressionModel/ParamMatrix/PCell/@beta'

    Use safe navigation (&.) instead of checking if an object exists before calling the method.
    Open

            next_step = curr.children.find { |c| c && c.true?(features) }
    Severity: Minor
    Found in lib/scoruby/models/decision_tree.rb by rubocop

    This cop transforms usages of a method call safeguarded by a non nil check for the variable whose method is being called to safe navigation (&.).

    Configuration option: ConvertCodeThatCanStartToReturnNil The default for this is false. When configured to true, this will check for code in the format !foo.nil? && foo.bar. As it is written, the return of this code is limited to false and whatever the return of the method is. If this is converted to safe navigation, foo&.bar can start returning nil as well as what the method returns.

    Example:

    # bad
    foo.bar if foo
    foo.bar(param1, param2) if foo
    foo.bar { |e| e.something } if foo
    foo.bar(param) { |e| e.something } if foo
    
    foo.bar if !foo.nil?
    foo.bar unless !foo
    foo.bar unless foo.nil?
    
    foo && foo.bar
    foo && foo.bar(param1, param2)
    foo && foo.bar { |e| e.something }
    foo && foo.bar(param) { |e| e.something }
    
    # good
    foo&.bar
    foo&.bar(param1, param2)
    foo&.bar { |e| e.something }
    foo&.bar(param) { |e| e.something }
    
    foo.nil? || foo.bar
    !foo || foo.bar
    
    # Methods that `nil` will `respond_to?` should not be converted to
    # use safe navigation
    foo.to_i if foo

    Space between { and | missing.
    Open

              @xml.xpath(COEFFICIENTS_VALUES_PATH).map{|attribute| attribute.value.to_f}

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Line is too long. [84/80]
    Open

          return Models::LogisticRegression::Model.new(xml) if logistic_regression?(xml)
    Severity: Minor
    Found in lib/scoruby/model_factory.rb by rubocop

    Line is too long. [97/80]
    Open

            COEFFICIENTS_LABELS_PATH = '//PMML/GeneralRegressionModel/ParameterList/Parameter/@label'

    Space missing to the left of {.
    Open

              @xml.xpath(COEFFICIENTS_VALUES_PATH).map{|attribute| attribute.value.to_f}

    Checks that block braces have or don't have a space before the opening brace depending on configuration.

    Example:

    # bad
    foo.map{ |a|
      a.bar.to_s
    }
    
    # good
    foo.map { |a|
      a.bar.to_s
    }

    Line is too long. [84/80]
    Open

              @xml.xpath(COEFFICIENTS_VALUES_PATH).map{|attribute| attribute.value.to_f}

    Line is too long. [100/80]
    Open

                  response: sum(decisions_count.map { |k, v| k.to_f * v }) / sum(decisions_count.values)
    Severity
    Category
    Status
    Source
    Language