SciRuby/statsample

View on GitHub

Showing 133 of 133 total issues

Method initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def initialize(opts=Hash.new)
        @name=@name_numerator=@name_denominator=nil
        
        # First see if sum of squares or mean squares are entered
        raise ArgumentError, "You should set d.f." unless (opts.has_key? :df_num and opts.has_key? :df_den)
Severity: Minor
Found in lib/statsample/anova/oneway.rb - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                 bp.rule do |r|
                  r.visible {|v| v[:percentil_75] < v[:high_whisker]}
                  r.bottom {|v| y_scale.scale(v[:percentil_75])}              
                  r.left {|v| x_scale.range_band / 2.0}
                  r.height {|v| y_scale.scale(v[:high_whisker]) - y_scale.scale(v[:percentil_75])}
    Severity: Major
    Found in lib/statsample/graph/boxplot.rb and 1 other location - About 1 hr to fix
    lib/statsample/graph/boxplot.rb on lines 191..195

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 48.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                bp.rule do |r|
                  r.visible {|v| v[:percentil_25] > v[:low_whisker]}
                  r.bottom {|v| y_scale[v[:low_whisker]]}              
                  r.left {|v| x_scale.range_band / 2.0}
                  r.height {|v| y_scale.scale(v[:percentil_25]) - y_scale.scale(v[:low_whisker])}
    Severity: Major
    Found in lib/statsample/graph/boxplot.rb and 1 other location - About 1 hr to fix
    lib/statsample/graph/boxplot.rb on lines 204..208

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 48.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          def covariance_matrix(ds)
            vars,cases = ds.ncols, ds.nrows
            if !ds.include_values?(*Daru::MISSING_VALUES) and Statsample.has_gsl? and prediction_optimized(vars,cases) < prediction_pairwise(vars,cases)
              cm=covariance_matrix_optimized(ds)
            else
    Severity: Minor
    Found in lib/statsample/bivariate.rb and 1 other location - About 55 mins to fix
    lib/statsample/bivariate.rb on lines 199..208

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method prop_pearson has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def prop_pearson(t, size, tails=:both)
            tails=:both if tails==2
            tails=:right if tails==1 or tails==:positive
            tails=:left if tails==:negative
            
    Severity: Minor
    Found in lib/statsample/bivariate.rb - About 55 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          def correlation_matrix(ds)
            vars, cases = ds.ncols, ds.nrows
            if !ds.include_values?(*Daru::MISSING_VALUES) and Statsample.has_gsl? and prediction_optimized(vars,cases) < prediction_pairwise(vars,cases)
              cm=correlation_matrix_optimized(ds)
            else
    Severity: Minor
    Found in lib/statsample/bivariate.rb and 1 other location - About 55 mins to fix
    lib/statsample/bivariate.rb on lines 160..169

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method constant_se has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def constant_se
        return nil if @no_covariance
        means=@x_mean
        #means[@y_var]=@y_mean
        means[:constant]=1
    Severity: Minor
    Found in lib/statsample/regression/multiple/matrixengine.rb - About 55 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

    Method iterate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def iterate(m=nil)
          @clean=false
          m||=@m
          @m=m
          t = @max_iterations
    Severity: Minor
    Found in lib/statsample/factor/principalaxis.rb - About 55 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

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

      def initialize(matrix,y_var, opts=Hash.new)
        matrix.extend Statsample::CovariateMatrix
        raise "#{y_var} variable should be on data" unless matrix.fields.include? y_var
        if matrix._type==:covariance
          @matrix_cov=matrix
    Severity: Minor
    Found in lib/statsample/regression/multiple/matrixengine.rb - About 55 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

    Method init_gsl has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def init_gsl(a,b,cov00, cov01, covx1, chisq, status)
    Severity: Major
    Found in lib/statsample/regression/simple.rb - About 50 mins to fix

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            def icc_1_k_ci(alpha=0.05)
              per=1-(0.5*alpha)
              fu=icc_1_f.f*Distribution::F.p_value(per, @df_wt, @df_bt)
              fl=icc_1_f.f.quo(Distribution::F.p_value(per, @df_bt, @df_wt))
              [1-1.quo(fl), 1-1.quo(fu)]
      Severity: Major
      Found in lib/statsample/reliability/icc.rb and 2 other locations - About 45 mins to fix
      lib/statsample/reliability/icc.rb on lines 392..396
      lib/statsample/reliability/icc.rb on lines 399..403

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 41.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            def icc_3_k_ci(alpha=0.05)
              per=1-(0.5*alpha)
              fl=icc_3_f.f.quo(Distribution::F.p_value(per, @df_bt, @df_residual))
              fu=icc_3_f.f*Distribution::F.p_value(per, @df_residual, @df_bt)
              [1-1.quo(fl),1-1.quo(fu)]
      Severity: Major
      Found in lib/statsample/reliability/icc.rb and 2 other locations - About 45 mins to fix
      lib/statsample/reliability/icc.rb on lines 322..326
      lib/statsample/reliability/icc.rb on lines 399..403

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 41.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

            def icc_c_k_ci(alpha=0.05)
              per=1-(0.5*alpha)
              fl=icc_c_k_f.f.quo(Distribution::F.p_value(per, @df_bt, @df_residual))
              fu=icc_c_k_f.f*Distribution::F.p_value(per, @df_residual, @df_bt)
              [1-1.quo(fl),1-1.quo(fu)]
      Severity: Major
      Found in lib/statsample/reliability/icc.rb and 2 other locations - About 45 mins to fix
      lib/statsample/reliability/icc.rb on lines 322..326
      lib/statsample/reliability/icc.rb on lines 392..396

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 41.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          def self.separate_matrices(matrix, y)
            ac=[]
            matrix.column_size.times do |i|
              ac.push(matrix[y,i]) if i!=y
            end
      Severity: Minor
      Found in lib/statsample/factor/principalaxis.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

      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

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

          def increment(x, w=1)
            if x.respond_to? :each
              x.each{|y| increment(y,w) }
            elsif x.is_a? Numeric
              (range.size - 1).times do |i|
      Severity: Minor
      Found in lib/statsample/histogram.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

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

              def report_building(b)
                di="%0.#{digits}f"
                b.section(:name=>@name) do |g|
                  c=coeffs
                  g.text _("Engine: %s") % self.class
      Severity: Minor
      Found in lib/statsample/regression/multiple/baseengine.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

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

            def initialize(opts=Hash.new)
              @name=@name_numerator=@name_denominator=nil
              
              # First see if sum of squares or mean squares are entered
              raise ArgumentError, "You should set d.f." unless (opts.has_key? :df_num and opts.has_key? :df_den)
      Severity: Minor
      Found in lib/statsample/anova/oneway.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

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

          def p_using_cdf(cdf, tails=:both)
            tails=:both if tails==2 or tails==:two
            tails=:right if tails==1 or tails==:positive
            tails=:left if tails==:negative
            case tails
      Severity: Minor
      Found in lib/statsample/test.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

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

          def self.nice(s, e) # :nodoc:
            reverse = e < s
            min = reverse ? e : s
            max = reverse ? s : e
            span = max - min
      Severity: Minor
      Found in lib/statsample.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

      Severity
      Category
      Status
      Source
      Language