weshatheleopard/rubyXL

View on GitHub
lib/rubyXL/objects/workbook.rb

Summary

Maintainability
C
1 day
Test Coverage

File workbook.rb has 445 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'date'
require 'rubyXL/objects/ooxml_object'
require 'rubyXL/objects/shared_strings'
require 'rubyXL/objects/stylesheet'
require 'rubyXL/objects/theme'
Severity: Minor
Found in lib/rubyXL/objects/workbook.rb - About 6 hrs to fix

    Class Workbook has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Workbook < OOXMLTopLevelObject
        CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'.freeze
        CONTENT_TYPE_TEMPLATE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml'.freeze
        CONTENT_TYPE_TEMPLATE_WITH_MACROS = 'application/vnd.ms-excel.template.macroEnabled.main+xml'.freeze
        CONTENT_TYPE_WITH_MACROS = 'application/vnd.ms-excel.sheet.macroEnabled.main+xml'.freeze
    Severity: Minor
    Found in lib/rubyXL/objects/workbook.rb - About 3 hrs to fix

      Method initialize has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(worksheets = [], src_file_path = nil, creator = nil, modifier = nil, created_at = nil,
                         company = '', application = APPLICATION, appversion = APPVERSION, date1904 = 0,
                         is_template = false)
      Severity: Major
      Found in lib/rubyXL/objects/workbook.rb - About 1 hr to fix

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

            def before_write_xml
              max_sheet_id = worksheets.collect(&:sheet_id).compact.max || 0
        
              self.sheets = RubyXL::Sheets.new
        
        
        Severity: Minor
        Found in lib/rubyXL/objects/workbook.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