lib/rubyXL/objects/workbook.rb
File workbook.rb
has 445 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require 'date'
require 'rubyXL/objects/ooxml_object'
require 'rubyXL/objects/shared_strings'
require 'rubyXL/objects/stylesheet'
require 'rubyXL/objects/theme'
Class Workbook
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
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
Method initialize
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
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)
Method before_write_xml
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def before_write_xml
max_sheet_id = worksheets.collect(&:sheet_id).compact.max || 0
self.sheets = RubyXL::Sheets.new
- Read upRead up
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 num_to_date
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def num_to_date(num)
return nil if num.nil?
# Bug-for-bug Excel compatibility (https://support.microsoft.com/kb/214058/)
if num < MARCH_1_1900 then
- Read upRead up
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"