SciRuby/statsample

View on GitHub

Showing 95 of 133 total issues

File matrix.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ::Vector
  def to_matrix
    ::Matrix.columns([self.to_a])
  end
  def to_vector
Severity: Minor
Found in lib/statsample/matrix.rb - About 2 hrs to fix

    File multiset.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Statsample
      # Multiset joins multiple dataset with the same fields and vectors
      # but with different number of cases. 
      # This is the base class for stratified and cluster sampling estimation
      class Multiset
    Severity: Minor
    Found in lib/statsample/multiset.rb - About 2 hrs to fix

      Method initialize has 50 lines of code (exceeds 25 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 2 hrs to fix

        Method write has a Cognitive Complexity of 14 (exceeds 5 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

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

            def table_percentage(generator,type)
              fq=frequencies
              cn=cols_names
              rn=rows_names
              rt=rows_total
        Severity: Minor
        Found in lib/statsample/crosstab.rb - About 1 hr to fix

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

                def report_building(builder)
                  builder.section(:name=>@name) do |generator|
                    fq=frequencies
                    rn=rows_names
                    cn=cols_names
            Severity: Minor
            Found in lib/statsample/crosstab.rb - About 1 hr to fix

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

                    def initialize(opts=Hash.new)
                      # First see if sum of squares or mean squares are entered
                      raise ArgumentError, "You should set all d.f." unless [:df_a, :df_b, :df_within].all? {|v| opts.has_key? v}
                      
                      @df_a=opts.delete :df_a
              Severity: Minor
              Found in lib/statsample/anova/twoway.rb - About 1 hr to fix

                Method submatrix has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def submatrix(rows,columns = nil)
                      raise ArgumentError, "rows shouldn't be empty" if rows.respond_to? :size and rows.size == 0
                      columns ||= rows
                      # Convert all fields on index
                      row_index = rows.collect do |v|
                Severity: Minor
                Found in lib/statsample/matrix.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 13 (exceeds 5 allowed). Consider refactoring.
                Open

                      def report_building(g) #:nodoc:
                        g.section(:name=>@name) do |s|
                          s.text _("Bootstrap Method: %s") % bootstrap_method
                          s.text _("Uses SMC: %s") % (smc ? _("Yes") : _("No"))
                          s.text _("Correlation Matrix type : %s") % matrix_method
                Severity: Minor
                Found in lib/statsample/factor/parallelanalysis.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 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def report_building(builder) # :nodoc:
                        raise "You should bootstrap first" if @n_samples==0
                        builder.section(:name=>@name) do |generator|
                          generator.text _("Sample size: %d\n") % @n_samples
                          generator.text "t: #{t}\n"
                Severity: Minor
                Found in lib/statsample/dominanceanalysis/bootstrap.rb - About 1 hr to fix

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

                      def report_building(generator)
                        iterate if @clean
                        generator.section(:name=>@name) do |s|
                          s.text _("Number of factors: %d") % m
                          s.text _("Iterations: %d") % @iterations
                  Severity: Minor
                  Found in lib/statsample/factor/principalaxis.rb - About 1 hr to fix

                    Method pairs has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def pairs(matrix)
                            # calculate concordant #p matrix
                            rs=matrix.row_size
                            cs=matrix.column_size
                            conc=disc=ties_x=ties_y=0
                    Severity: Minor
                    Found in lib/statsample/bivariate.rb - About 1 hr to fix

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

                            def compute
                              gsl_m=(use_gsl and Statsample.has_gsl?) ? @matrix.to_gsl : @matrix
                              klass_m=gsl_m.class
                              eigvect,@eigenvalues=gsl_m.eigenvectors_matrix, gsl_m.eigenvalues
                              eigenvalues_sqrt=@eigenvalues.collect {|v| Math.sqrt(v)}
                      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 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 report_building has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def report_building(builder)
                            builder.section(:name=>@name) do |generator|
                              fq=frequencies
                              rn=rows_names
                              cn=cols_names
                      Severity: Minor
                      Found in lib/statsample/crosstab.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 out has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                  def out(dataset,opt={})
                                      require 'ostruct'
                                      default_opt = {:dataname => "Default", :description=>"", :missing=>"NA"}
                                      default_opt.merge! opt
                                      carrier=OpenStruct.new
                      Severity: Minor
                      Found in lib/statsample/converters.rb - About 1 hr to fix

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

                              def compute
                                @original=Statsample::Bivariate.send(matrix_method, @ds).eigenvalues unless no_data
                                @ds_eigenvalues=Daru::DataFrame.new({}, order: (1..@n_variables).map{|v| ("ev_%05d" % v).to_sym})
                                
                                if bootstrap_method==:parameter or bootstrap_method==:random
                        Severity: Minor
                        Found in lib/statsample/factor/parallelanalysis.rb - About 1 hr to fix

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

                                def compute
                                  gsl_m=(use_gsl and Statsample.has_gsl?) ? @matrix.to_gsl : @matrix
                                  klass_m=gsl_m.class
                                  eigvect,@eigenvalues=gsl_m.eigenvectors_matrix, gsl_m.eigenvalues
                                  eigenvalues_sqrt=@eigenvalues.collect {|v| Math.sqrt(v)}
                          Severity: Minor
                          Found in lib/statsample/factor/map.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language