SciRuby/statsample

View on GitHub
lib/statsample/converters.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

                  def variable_definition(carrier,v,name,nickname=nil)
                      nickname = (nickname.nil? ? "" : "nickname=\"#{nickname}\"" )
                      if v.type==:object or v.to_a.find {|d|  d.is_a? String }
                          carrier.categorials.push(name)
                          carrier.conversions[name]={}
      Severity: Minor
      Found in lib/statsample/converters.rb - About 35 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