Showing 29 of 29 total issues

Function exports has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(api) {
  var validEnv = ['development', 'test', 'production']
  var currentEnv = api.env()
  var isDevelopmentEnv = api.env('development')
  var isProductionEnv = api.env('production')
Severity: Major
Found in babel.config.js - About 2 hrs to fix

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

      class FileParser
        attr_accessor :load_errors, :plot_errors, :measurements, :plot,
                      :sample, :sample_type_id, :sample_date
    
        def initialize(date, id)
    Severity: Minor
    Found in app/lib/parsers/file_parser.rb - About 2 hrs to fix

      Method for has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.for(sample_type_id,date)
            klass = case sample_type_id
                    when 1 then Parsers::LysimeterParser
                    when 2 then Parsers::GenericParser # LterSoilParser
                    # when 3 then Parsers::StandardParser # deprecated
      Severity: Minor
      Found in app/lib/parsers.rb - About 1 hr to fix

        Method seed has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def seed
          [1, 2, 3, 4, 5, 6, 7, 8, '8nt'].each do |trt|
            1.upto(6) do |rep|
              1.upto(5) do |stn|
                1.upto(2) do |core|
        Severity: Minor
        Found in seed-deepcore.rb - About 1 hr to fix

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

            class GlbrcCnRootSoilParser < CNSampleParser
          
              CN_ROOT_SOIL_SAMPLE =
                '(\d+),\d+,(G.?.R\dC[C|I])-(\d+)-[abc|ABC],\d+\.\d+,\w+,\w+,,,,(\d+(?:\.\d+)?),(\d+(?:\.\d+)?)'
          
          
          Severity: Major
          Found in app/lib/parsers/glbrc_cn_root_soil_parser.rb and 1 other location - About 1 hr to fix
          app/lib/parsers/glbrc_cn_pit_root_parser.rb on lines 5..29

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

          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

            class GlbrcCnPitRootParser < CNSampleParser
              CN_ROOT_SAMPLE =
                '(\d+),\d+,(G.?.R\du?h)-(\w+)-[abc|ABC],\d+\.\d+,\w+,\w+,,,,(\d+(?:\.\d+)?),(\d+(?:\.\d+)?)'
          
              def process_line(line)
          Severity: Major
          Found in app/lib/parsers/glbrc_cn_pit_root_parser.rb and 1 other location - About 1 hr to fix
          app/lib/parsers/glbrc_cn_root_soil_parser.rb on lines 5..29

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

          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

              1.upto(6) do |rep|
                1.upto(5) do |stn|
                  1.upto(2) do |core|
                    [10,25,50,122].each do |depth|
                      plot = "T#{trt.to_s.rjust(2,'0')}R#{rep}S#{stn}C#{core}-#{depth}"
          Severity: Major
          Found in seed-deepcore.rb and 1 other location - About 1 hr to fix
          seed-deepcore.rb on lines 24..29

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

          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

              1.upto(3) do |rep|
                1.upto(5) do |stn|
                  1.upto(2) do |core|
                    [10,25,50,122].each do |depth|
                      plot = "T#{trt.to_s.rjust(2,'0')}R#{rep}S#{stn}C#{core}-#{depth}"
          Severity: Major
          Found in seed-deepcore.rb and 1 other location - About 1 hr to fix
          seed-deepcore.rb on lines 12..17

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

          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

            class GlbrcCnRootExcavationPlantParser < CNSampleParser
              CN_PLANT_SAMPLE =
                '(\d+),.+,(\d+)?([G|L|M]..R?\d?-?\S+)-[abc|ABC],.+,(\d+(?:\.\d+)?),(\d+(?:\.\d+)?)'
          
              # https://rubular.com/r/g2cytUECX1jQjT
          Severity: Major
          Found in app/lib/parsers/glbrc_cn_root_excavation_plant_parser.rb and 1 other location - About 1 hr to fix
          app/lib/parsers/glbrc_cn_plant_parser.rb on lines 5..22

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

          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

            class GlbrcCnPlantParser < CNSampleParser
              CN_PLANT_SAMPLE =
                '(\d+),.+,(\d+)?([G|L|M]..R?\d?-?\S+)[abc|ABC],.+,(\d+(?:\.\d+)?),(\d+(?:\.\d+)?)'
          
              def process_line(line)
          Severity: Major
          Found in app/lib/parsers/glbrc_cn_plant_parser.rb and 1 other location - About 1 hr to fix
          app/lib/parsers/glbrc_cn_root_excavation_plant_parser.rb on lines 5..23

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

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

              def self.parse(line)
                data = CSV.parse_line(line)
          
                return nil unless data[1] == "Unknown"
          
          
          Severity: Minor
          Found in app/lib/parsers/lachat_generic_line_parser.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

            1.upto(4) do |rep|
              1.upto(10) do |stn|
                [10,25,50,100].each do |depth|
                  plot = "M#{rep}R1S#{stn}C1-#{depth}"
                  p Plot.where(name: plot, study_id: 11).first_or_create(name: plot, study_id: 11, bottom_depth: depth, top_depth: top_depth(depth))
          Severity: Major
          Found in seed-deepcore.rb and 1 other location - About 1 hr to fix
          seed-deepcore.rb on lines 35..39

          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

            1.upto(3) do |rep|
              1.upto(10) do |stn|
                [10,25,50,100].each do |depth|
                  plot = "L#{rep}R1S#{stn}C1-#{depth}"
                  p Plot.where(name: plot, study_id: 11).first_or_create(name: plot, study_id: 11, bottom_depth: depth, top_depth: top_depth(depth))
          Severity: Major
          Found in seed-deepcore.rb and 1 other location - About 1 hr to fix
          seed-deepcore.rb on lines 43..47

          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

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

              def process_line(line, line_parser)
                first, second, nh4_amount, no3_amount, raw_sample_date, modifier, site = line_parser.parse(line)
                if raw_sample_date
                  self.sample_date = raw_sample_date
                end
          Severity: Minor
          Found in app/lib/parsers/standard_parser.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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.parse(line)
                data = CSV.parse_line(line)
          
                return nil unless data[1] == "Unknown"
                return nil if data[0] =~ /1\s*M\s+KCL/i
          Severity: Minor
          Found in app/lib/parsers/lachat_standard_line_parser.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 make_plot_with_prefix has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def make_plot_with_prefix(prefix, first, second, modifier, site)
          Severity: Minor
          Found in app/lib/parsers/standard_parser.rb - About 35 mins to fix

            Method parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.parse(line)
                  data = CSV.parse(line)[0]
                  return nil unless data[1] == "Unknown"
                  return nil if data[0] =~ /1\s.M\s+KCL/i
                  return nil if data[0] =~ /H2O/i
            Severity: Minor
            Found in app/lib/parsers/lachat_lysimeter_line_parser.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

            Method process_line has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def process_line(line)
                  re = Regexp.new(GLBRC_DEEP_CORE)
                  plot_name, nh4_amount, no3_amount = re.match(line).try(:captures)
                  if plot_name && nh4_amount && no3_amount
                    find_plot(plot_name) unless self.plot.try(:name) == plot_name
            Severity: Minor
            Found in app/lib/parsers/glbrc_deep_parser.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

            Avoid too many return statements within this method.
            Open

                  return nil if data[0] =~ /BLK/i
            Severity: Major
            Found in app/lib/parsers/lachat_standard_line_parser.rb - About 30 mins to fix

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

                class LysimeterLineParser
                  LYSIMETER =
                    '(\w{1,2})-(\d)-(\d)[ABC|abc], (\d{8})\s+-?\d+\t\s+(-?\d+\.\d+)\t\w*\t+\s+-?\d+\t\s+(-?\d+\.\d+)'
              
                  def self.parse(line)
              Severity: Minor
              Found in app/lib/parsers/lysimeter_line_parser.rb and 1 other location - About 30 mins to fix
              app/lib/parsers/old_lysimeter_line_parser.rb on lines 4..11

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

              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