SciRuby/statsample

View on GitHub
lib/statsample/dominanceanalysis.rb

Summary

Maintainability
D
1 day
Test Coverage

File dominanceanalysis.rb has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Statsample
  # Dominance Analysis is a procedure based on an examination of the R<sup>2</sup> values
  # for all possible subset models, to identify the relevance of one or more 
  # predictors in the prediction of criterium.
  #
Severity: Minor
Found in lib/statsample/dominanceanalysis.rb - About 3 hrs to fix

    Class DominanceAnalysis has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class DominanceAnalysis
        include Summarizable
        # Class to generate the regressions. Default to Statsample::Regression::Multiple::MatrixEngine
        attr_accessor :regression_class
        # Name of analysis
    Severity: Minor
    Found in lib/statsample/dominanceanalysis.rb - About 2 hrs to fix

      Method report_building has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def report_building(g)
            compute if @models.nil?
            g.section(:name=>@name) do |generator|
              header=["","r2",_("sign")]+@predictors.collect {|c| DominanceAnalysis.predictor_name(c) }
              
      Severity: Minor
      Found in lib/statsample/dominanceanalysis.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 report_building has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def report_building(g)
            compute if @models.nil?
            g.section(:name=>@name) do |generator|
              header=["","r2",_("sign")]+@predictors.collect {|c| DominanceAnalysis.predictor_name(c) }
              
      Severity: Minor
      Found in lib/statsample/dominanceanalysis.rb - About 1 hr to fix

        Method initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(input, dependent, opts=Hash.new)
              @build_from_dataset=false
              if dependent.is_a? Array
                @regression_class= MULTIVARIATE_REGRESSION_CLASS
                @method_association=:r2yx
        Severity: Minor
        Found in lib/statsample/dominanceanalysis.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 total_dominance_pairwise has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def total_dominance_pairwise(i,j)
              dm=dominance_for_nil_model(i,j)
              return 0.5 if dm==0.5
              dominances=[dm]
              models_data.each do |k,m|
        Severity: Minor
        Found in lib/statsample/dominanceanalysis.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 initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize(input, dependent, opts=Hash.new)
              @build_from_dataset=false
              if dependent.is_a? Array
                @regression_class= MULTIVARIATE_REGRESSION_CLASS
                @method_association=:r2yx
        Severity: Minor
        Found in lib/statsample/dominanceanalysis.rb - About 1 hr to fix

          Method conditional_dominance_pairwise has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def conditional_dominance_pairwise(i,j)
                dm=dominance_for_nil_model(i,j)
                return 0.5 if dm==0.5
                dominances=[dm]
                for k in 1...@predictors.size
          Severity: Minor
          Found in lib/statsample/dominanceanalysis.rb - About 45 mins 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

          There are no issues that match your filters.

          Category
          Status