SciRuby/statsample

View on GitHub

Showing 133 of 133 total issues

Method tetrachoric_correlation_matrix has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def tetrachoric_correlation_matrix(ds)
        dsv=ds.reject_values(*Daru::MISSING_VALUES)
        # Delete all vectors doesn't have variation
        dsv.vectors.each { |f|
          if dsv[f].factors.size==1
Severity: Minor
Found in lib/statsample/converter/spss.rb - About 1 hr to fix

    Method report_building has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def report_building(b) # :nodoc:
            b.section(:name=>name) do |s|
              s.section(:name=>_("Reliability analysis of scales")) do |s2|
                @scales.each_pair do |k, scale|
                  s2.parse_element(scale)
    Severity: Minor
    Found in lib/statsample/reliability/multiscaleanalysis.rb - About 1 hr to fix

      Method iterate has 32 lines of code (exceeds 25 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 1 hr to fix

        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 rubyvis_panel has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def rubyvis_panel # :nodoc:
                pre_vis
                #that=self
                
                @minimum_x||=@hist.min
        Severity: Minor
        Found in lib/statsample/graph/histogram.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 a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def report_building(builder)
                builder.section(:name=>@name) do |s|
                  sa = scale_analysis
                  s.parse_element(sa)
                  if summary_show_problematic_items
        Severity: Minor
        Found in lib/statsample/reliability/skillscaleanalysis.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 write has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def write(dataset,filename,type=:covariance)
                puts "Writing MX File"
                File.open(filename,"w") do |fp|
                  fp.puts "! #{filename}"
                  fp.puts "! Output generated by Statsample"
        Severity: Minor
        Found in lib/statsample/converters.rb - About 1 hr to fix

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

                    def initialize(ds,y_var, opts=Hash.new)
                      super
                      @ds          = ds.reject_values(*Daru::MISSING_VALUES)
                      @ds_valid    = @ds
                      @valid_cases = @ds_valid.nrows
          Severity: Minor
          Found in lib/statsample/regression/multiple/gslengine.rb - About 1 hr to fix

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

                  def initialize(ds, opts=Hash.new)
                    @dumped=ds.vectors.to_a.find_all {|f|
                      ds[f].variance == 0
                    }
                    
            Severity: Minor
            Found in lib/statsample/reliability/scaleanalysis.rb - About 1 hr to fix

              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 to_multiset_by_split_multiple_fields has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def to_multiset_by_split_multiple_fields(*fields)
                      fields.map!(&:to_sym)
                      factors_total=nil
                      fields.each do |f|
                        if factors_total.nil?
                Severity: Minor
                Found in lib/statsample/daru.rb - About 1 hr to fix

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

                      def initialize(matrix, opts=Hash.new)
                        @matrix=matrix
                        if @matrix.respond_to? :fields
                          @fields=@matrix.fields
                        else
                  Severity: Minor
                  Found in lib/statsample/factor/principalaxis.rb - About 1 hr to fix

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

                          def report_building(g) #:nodoc:
                            g.section(:name=>@name) do |s|
                              s.table(:name=>_("Eigenvalues"),:header=>[_("Value")]) do |t|
                                eigenvalues.each_with_index do |e,i|
                                    t.row([@errors.include?(i) ? "*" : "%0.6f" % e])
                    Severity: Minor
                    Found in lib/statsample/factor/map.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(matrix, opts=Hash.new)
                          @use_gsl = opts[:use_gsl]
                          opts.delete :use_gsl
                    
                          @name=_("Principal Component Analysis")
                    Severity: Minor
                    Found in lib/statsample/factor/pca.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 kmo_univariate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def self.kmo_univariate(matrix, var)
                          if var.is_a? String
                            if matrix.respond_to? :fields
                              j=matrix.fields.index(var)
                              raise "Matrix doesn't have field #{var}" if j.nil?
                    Severity: Minor
                    Found in lib/statsample/factor.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 fix_with_regression has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def fix_with_regression
                        i = 0
                        @ds_indep.each(:row) do |row|
                          empty = []
                          row.each { |k,v| empty.push(k) if v.nil? }
                    Severity: Minor
                    Found in lib/statsample/regression/multiple/rubyengine.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def report_building(b) # :nodoc:
                            b.section(:name=>name) do |s|
                              s.section(:name=>_("Reliability analysis of scales")) do |s2|
                                @scales.each_pair do |k, scale|
                                  s2.parse_element(scale)
                    Severity: Minor
                    Found in lib/statsample/reliability/multiscaleanalysis.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 _recode_dataset has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def _recode_dataset(dataset, h , sep=Statsample::SPLIT_TOKEN, split=false)
                            v_names||=h.keys
                            v_names.each do |v_name|
                              raise Exception, "Vector #{v_name} doesn't exists on Dataset" if !dataset.vectors.include? v_name
                              recoded = Daru::Vector.new(
                    Severity: Minor
                    Found in lib/statsample/codification.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

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

                          def icc_3_1_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)
                            [(fl-1).quo(fl+k-1), (fu-1).quo(fu+k-1)]
                    Severity: Major
                    Found in lib/statsample/reliability/icc.rb and 1 other location - About 1 hr to fix
                    lib/statsample/reliability/icc.rb on lines 312..318

                    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 49.

                    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 icc_1_1_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))
                    Severity: Major
                    Found in lib/statsample/reliability/icc.rb and 1 other location - About 1 hr to fix
                    lib/statsample/reliability/icc.rb on lines 385..389

                    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 49.

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language