9troisquarts/ntq-excelsior

View on GitHub

Showing 17 of 211 total issues

Method add_sheet_content has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def add_sheet_content(content, wb_styles, sheet)
      content[:rows].each_with_index do |row, index|
        row_style = []
        if row[:styles].is_a?(Array) && row[:styles].any?
          row[:styles].each do |style|
Severity: Minor
Found in lib/ntq_excelsior/exporter.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

Class Importer has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Importer
    attr_accessor :file, :check, :lines, :options, :status_tracker, :success
    attr_accessor :context

    class << self
Severity: Minor
Found in lib/ntq_excelsior/importer.rb - About 3 hrs to fix

    Method detect_header_scheme has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def detect_header_scheme
          return @header_scheme if @header_scheme
    
          @header_scheme = {}
          # Read the first line of file (not header)
    Severity: Minor
    Found in lib/ntq_excelsior/importer.rb - About 2 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

    File exporter.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'caxlsx'
    
    module NtqExcelsior
      class Exporter
        attr_accessor :data
    Severity: Minor
    Found in lib/ntq_excelsior/exporter.rb - About 2 hrs to fix

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

        class Exporter
          attr_accessor :data
          attr_accessor :context
          attr_accessor :progression_tracker
      
      
      Severity: Minor
      Found in lib/ntq_excelsior/exporter.rb - About 2 hrs to fix

        Method spreadsheet_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def spreadsheet_data
              begin
                spreadsheet_data = spreadsheet.sheet(spreadsheet.sheets[0]).parse(header_search: required_headers)
                raise 'File is inconsistent, please check you have data in it or check for invalid characters in headers like , / ; etc...' unless spreadsheet_data.size > 0
        
        
        Severity: Minor
        Found in lib/ntq_excelsior/importer.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_line has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def import_line(line, save: true)
              record = find_or_initialize_record(line)
              return { status: :not_found } unless record
        
              @success = false
        Severity: Minor
        Found in lib/ntq_excelsior/importer.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 resolve_header_row has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def resolve_header_row(headers, index)
              row = { values: [], styles: [], merge_cells: [], height: nil }
              return row unless headers
        
              col_index = 1
        Severity: Minor
        Found in lib/ntq_excelsior/exporter.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 add_sheet_content has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def add_sheet_content(content, wb_styles, sheet)
              content[:rows].each_with_index do |row, index|
                row_style = []
                if row[:styles].is_a?(Array) && row[:styles].any?
                  row[:styles].each do |style|
        Severity: Minor
        Found in lib/ntq_excelsior/exporter.rb - About 1 hr to fix

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

              def import(save: true, status_tracker: nil)
                self.class.before.call(@context, options) if self.class.before.is_a?(Proc)
                at = 0
                errors_lines = []
                success_count = 0
          Severity: Minor
          Found in lib/ntq_excelsior/importer.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def import(save: true, status_tracker: nil)
                self.class.before.call(@context, options) if self.class.before.is_a?(Proc)
                at = 0
                errors_lines = []
                success_count = 0
          Severity: Minor
          Found in lib/ntq_excelsior/importer.rb - About 1 hr to fix

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

                def find_or_initialize_record(line)
                  return nil unless self.class.primary_key && self.class.model_klass
            
                  if line[self.class.primary_key.to_sym].present?
                    if self.class.primary_key.to_sym == :id
            Severity: Minor
            Found in lib/ntq_excelsior/importer.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 format_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def format_value(resolver, record)
                  styles = []
                  type = nil
                  if resolver.is_a?(Proc)
                    value = resolver.call(record) 
            Severity: Minor
            Found in lib/ntq_excelsior/exporter.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 resolve_record_row has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def resolve_record_row(schema, record, index)
                  row = { values: [], styles: [], merge_cells: [], height: nil, types: [] }
                  col_index = 1
                  schema.each do |column|
                    next unless column_is_visible?(column, record)
            Severity: Minor
            Found in lib/ntq_excelsior/exporter.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 number_of_headers_row has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def number_of_headers_row(columns, count = 1)
                  columns_with_children = columns.select{ |c| c[:children] && c[:children].any? }
                  return count unless columns_with_children && columns_with_children.size > 0
            
                  columns_with_children.each do |column|
            Severity: Minor
            Found in lib/ntq_excelsior/exporter.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 dig_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def dig_value(value, accessors = [])
                  v = value
                  return  v unless accessors && accessors.length > 0
            
                  return v.dig(*accessors) if v.is_a?(Hash)
            Severity: Minor
            Found in lib/ntq_excelsior/exporter.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

            Method content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def content
                  content = { rows: [] }
                  index = 0
                  (schema[:extra_headers] || []).each_with_index do |header|
                    index += 1
            Severity: Minor
            Found in lib/ntq_excelsior/exporter.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

            Severity
            Category
            Status
            Source
            Language