sue445/heart_seed

View on GitHub

Showing 6 of 6 total issues

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

    def self.read_sheet(sheet, row_prefix)
      header_keys = select_left_of_blank(sheet.row(HEADER_ROW))
      fixtures = {}

      (HEADER_ROW + 1 .. sheet.last_row).each do |row_num|
Severity: Minor
Found in lib/heart_seed/converter.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 import_all has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def self.import_all(seed_dir: HeartSeed::Helper.seed_dir, tables: ENV["TABLES"], catalogs: ENV["CATALOGS"], mode: ENV["MODE"], validate: true)
      mode ||= BULK
      target_table_names = parse_target_table_names(tables: tables, catalogs: catalogs)

      raise "require TABLES or CATALOGS if production" if HeartSeed::Helper.production? && target_table_names.empty?
Severity: Minor
Found in lib/heart_seed/db_seed.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 select_left_of_blank has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.select_left_of_blank(array)
      response = []
      array.each do |element|
        break unless element
        break if element.respond_to?(:blank?) && element.blank?
Severity: Minor
Found in lib/heart_seed/converter.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 environment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.environment(default = "development")
      env ||= Rails.env          if defined? Rails
      env ||= ENV["PADRINO_ENV"] if ENV["PADRINO_ENV"]
      env ||= ENV["RACK_ENV"]    if ENV["RACK_ENV"]
      env ||= default
Severity: Minor
Found in lib/heart_seed/helper.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

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

          ActiveRecord::Migration.say_with_time("#{file_path} -> #{table_name}") do
            insert_seed(file_path: file_path, table_name: table_name, mode: mode, validate: validate)
            ActiveRecord::Migration.say("[INFO] success", true)
Severity: Minor
Found in lib/heart_seed/db_seed.rb and 1 other location - About 15 mins to fix
lib/heart_seed/db_seed.rb on lines 87..89

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

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

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

          ActiveRecord::Migration.say_with_time("#{file_path} -> #{table_name}") do
            insert_seed(file_path: file_path, table_name: table_name, mode: mode, validate: validate)
            ActiveRecord::Migration.say("[INFO] success", true)
Severity: Minor
Found in lib/heart_seed/db_seed.rb and 1 other location - About 15 mins to fix
lib/heart_seed/db_seed.rb on lines 103..105

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

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