autotelik/datashift

View on GitHub
lib/datashift/exporters/excel_exporter.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method export_with_associations has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def export_with_associations(file_name, klass, export_records, options = {})

      records = [*export_records]

      state = DataShift::Configuration.call.with
Severity: Minor
Found in lib/datashift/exporters/excel_exporter.rb - About 1 hr to fix

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

        def export_with_associations(file_name, klass, export_records, options = {})
    
          records = [*export_records]
    
          state = DataShift::Configuration.call.with
    Severity: Minor
    Found in lib/datashift/exporters/excel_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 export has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def export(file, export_records, options = {})
          records = [*export_records]
    
          if records.blank?
            logger.warn('Excel Export - No objects supplied for export - no file written')
    Severity: Minor
    Found in lib/datashift/exporters/excel_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

    TODO found
    Open

    # TODO: Can we switch between .xls and XSSF (POI implementation of Excel 2007 OOXML (.xlsx) file format.)

    TODO found
    Open

          # TODO: - prepare_data_flow_schema here in middle of export, plus reaching through nodes to klass, does not smell right

    Do not place comments on the same line as the end keyword.
    Open

    end # DataShift

    This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

    Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

    Example:

    # bad
    if condition
      statement
    end # end if
    
    # bad
    class X # comment
      statement
    end
    
    # bad
    def x; end # comment
    
    # good
    if condition
      statement
    end
    
    # good
    class X # :nodoc:
      y
    end

    Do not place comments on the same line as the end keyword.
    Open

      end # ExcelGenerator

    This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

    Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

    Example:

    # bad
    if condition
      statement
    end # end if
    
    # bad
    class X # comment
      statement
    end
    
    # bad
    def x; end # comment
    
    # good
    if condition
      statement
    end
    
    # good
    class X # :nodoc:
      y
    end

    There are no issues that match your filters.

    Category
    Status