MiraitSystems/enju_trunk

View on GitHub
lib/enju_trunk/output_columns.rb

Summary

Maintainability
C
1 day
Test Coverage

Method initialize_output_column_spec has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize_output_column_spec(spec_hash = OUTPUT_COLUMN_SPEC, force_all = false)
        clear_cache!

        spec_file = "#{Rails.root}/lib/enju_trunk/columns_spec.csv"
        spec_file = Gem::Specification.find_by_name("enju_trunk").gem_dir + '/lib/enju_trunk/columns_spec.csv' unless File.exist?(spec_file)
Severity: Minor
Found in lib/enju_trunk/output_columns.rb - About 3 hrs 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_output_column_spec has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def select_output_column_spec(field, spec_hash = OUTPUT_COLUMN_SPEC)
        separation = separate_output_columns?
        if field == :all
          regexp = nil
        else
Severity: Minor
Found in lib/enju_trunk/output_columns.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_output_column_spec has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def initialize_output_column_spec(spec_hash = OUTPUT_COLUMN_SPEC, force_all = false)
        clear_cache!

        spec_file = "#{Rails.root}/lib/enju_trunk/columns_spec.csv"
        spec_file = Gem::Specification.find_by_name("enju_trunk").gem_dir + '/lib/enju_trunk/columns_spec.csv' unless File.exist?(spec_file)
Severity: Minor
Found in lib/enju_trunk/output_columns.rb - About 1 hr to fix

    Method add_output_column_spec has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def add_output_column_spec(fields, field_ext, field_names, for_join, for_separate, spec_hash = OUTPUT_COLUMN_SPEC)
            fields = [fields].flatten.map(&:to_s)
            unknown = fields - OUTPUT_COLUMN_FIELDS
            unless unknown.empty?
              raise ArgumentError, "unknown field: #{unknown.join(', ')}"
    Severity: Minor
    Found in lib/enju_trunk/output_columns.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 translation_for_output_columns has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def translation_for_output_columns
            translation = {}
            column_spec = {}
            initialize_output_column_spec(column_spec, true)
    
    
    Severity: Minor
    Found in lib/enju_trunk/output_columns.rb - About 1 hr to fix

      Method add_output_column_spec has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def add_output_column_spec(fields, field_ext, field_names, for_join, for_separate, spec_hash = OUTPUT_COLUMN_SPEC)
              fields = [fields].flatten.map(&:to_s)
              unknown = fields - OUTPUT_COLUMN_FIELDS
              unless unknown.empty?
                raise ArgumentError, "unknown field: #{unknown.join(', ')}"
      Severity: Minor
      Found in lib/enju_trunk/output_columns.rb - About 1 hr to fix

        Method add_output_column_spec has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def add_output_column_spec(fields, field_ext, field_names, for_join, for_separate, spec_hash = OUTPUT_COLUMN_SPEC)
        Severity: Minor
        Found in lib/enju_trunk/output_columns.rb - About 45 mins to fix

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

                def translation_for_output_columns
                  translation = {}
                  column_spec = {}
                  initialize_output_column_spec(column_spec, true)
          
          
          Severity: Minor
          Found in lib/enju_trunk/output_columns.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