taka0125/master_data_tool

View on GitHub
lib/master_data_tool/master_data.rb

Summary

Maintainability
B
5 hrs
Test Coverage
A
100%

Class MasterData has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class MasterData
    attr_reader :master_data_file, :model_klass, :columns, :new_records, :updated_records, :no_change_records, :deleted_records,
                :before_count, :after_count, :spec_config

    # @param [MasterDataTool::MasterDataFile] master_data_file
Severity: Minor
Found in lib/master_data_tool/master_data.rb - About 2 hrs to fix

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

        def verify!(ignore_fail: false)
          MasterDataTool::Report::VerifyReport.new(self).tap do |report|
            scoped = @model_klass.all
            scoped = scoped.preload(preload_associations) if preload_associations
            scoped = scoped.eager_load(eager_load_associations) if eager_load_associations
    Severity: Minor
    Found in lib/master_data_tool/master_data.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! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def import!(dry_run: true, delete_all_ignore_foreign_key: false)
          raise MasterDataTool::NotLoadedError unless @loaded
    
          MasterDataTool::Report::ImportReport.new(self).tap do |report|
            return report if dry_run
    Severity: Minor
    Found in lib/master_data_tool/master_data.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 load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def load
          csv = CSV.read(@master_data_file.path, headers: true, skip_blanks: true)
          old_records_by_id = @model_klass.all.index_by(&:id)
    
          csv_records_by_id = build_records_from_csv(csv, old_records_by_id)
    Severity: Minor
    Found in lib/master_data_tool/master_data.rb - About 25 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