weshatheleopard/rubyXL

View on GitHub

Showing 61 of 61 total issues

File theme.rb has 1462 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rubyXL/objects/ooxml_object'
require 'rubyXL/objects/extensions'

module RubyXL
  # http://www.datypic.com/sc/ooxml/e-a_ext-1.html
Severity: Major
Found in lib/rubyXL/objects/theme.rb - About 3 days to fix

    Method default has 317 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.default
          default_theme = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">
    <a:themeElements>
    <a:clrScheme name="Office">
    Severity: Major
    Found in lib/rubyXL/objects/theme.rb - About 1 day to fix

      File worksheet.rb has 622 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'rubyXL/objects/ooxml_object'
      require 'rubyXL/objects/simple_types'
      require 'rubyXL/objects/extensions'
      require 'rubyXL/objects/relationships'
      require 'rubyXL/objects/sheet_common'
      Severity: Major
      Found in lib/rubyXL/objects/worksheet.rb - About 1 day to fix

        File worksheet.rb has 543 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module RubyXL
          module WorksheetConvenienceMethods
            NAME = 0
            SIZE = 1
            COLOR = 2
        Severity: Major
        Found in lib/rubyXL/convenience_methods/worksheet.rb - About 1 day to fix

          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

            Method parse has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse(node, known_namespaces = nil)
                  case node
                  when String, IO, Zip::InputStream then node = Nokogiri::XML.parse(node)
                  end
            
            
            Severity: Minor
            Found in lib/rubyXL/objects/ooxml_object.rb - About 5 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              class CT_HslColor < OOXMLObject
                define_child_node(RubyXL::IntegerValue, :node_name => 'a:tint')
                define_child_node(RubyXL::IntegerValue, :node_name => 'a:shade')
                define_child_node(RubyXL::BooleanValue, :node_name => 'a:comp')
                define_child_node(RubyXL::BooleanValue, :node_name => 'a:inv')
            Severity: Major
            Found in lib/rubyXL/objects/theme.rb and 1 other location - About 5 hrs to fix
            lib/rubyXL/objects/theme.rb on lines 28..61

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 190.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              class CT_ScRgbColor < OOXMLObject
                # -- Choice [0..*] (a:EG_ColorTransform)
                define_child_node(RubyXL::IntegerValue, :node_name => 'a:tint')
                define_child_node(RubyXL::IntegerValue, :node_name => 'a:shade')
                define_child_node(RubyXL::BooleanValue, :node_name => 'a:comp')
            Severity: Major
            Found in lib/rubyXL/objects/theme.rb and 1 other location - About 5 hrs to fix
            lib/rubyXL/objects/theme.rb on lines 100..132

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 190.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method write_xml has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
            Open

                def write_xml(xml = nil, node_name_override = nil)
                  if xml.nil? then
                    seed_xml = Nokogiri::XML('<?xml version = "1.0" standalone ="yes"?>')
                    seed_xml.encoding = 'UTF-8'
            
            
            Severity: Minor
            Found in lib/rubyXL/objects/ooxml_object.rb - About 5 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              class CT_PresetColor < OOXMLObject
                define_child_node(RubyXL::IntegerValue, :node_name => 'a:tint')
                define_child_node(RubyXL::IntegerValue, :node_name => 'a:shade')
                define_child_node(RubyXL::BooleanValue, :node_name => 'a:comp')
                define_child_node(RubyXL::BooleanValue, :node_name => 'a:inv')
            Severity: Major
            Found in lib/rubyXL/objects/theme.rb and 1 other location - About 5 hrs to fix
            lib/rubyXL/objects/theme.rb on lines 171..201

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 179.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              class CT_SchemeColor < OOXMLObject
                define_child_node(RubyXL::IntegerValue, :node_name => 'a:tint')
                define_child_node(RubyXL::IntegerValue, :node_name => 'a:shade')
                define_child_node(RubyXL::BooleanValue, :node_name => 'a:comp')
                define_child_node(RubyXL::BooleanValue, :node_name => 'a:inv')
            Severity: Major
            Found in lib/rubyXL/objects/theme.rb and 1 other location - About 5 hrs to fix
            lib/rubyXL/objects/theme.rb on lines 205..235

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 179.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                def before_write_xml # This method may need to be moved higher in the hierarchy
                  first_nonempty_row = nil
                  last_nonempty_row = 0
                  first_nonempty_column = nil
                  last_nonempty_column = 0
            Severity: Minor
            Found in lib/rubyXL/objects/worksheet.rb - About 4 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 insert_row has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

                def insert_row(row_index = 0)
                  validate_workbook
                  ensure_cell_exists(row_index)
            
                  old_row = new_cells = nil
            Severity: Minor
            Found in lib/rubyXL/convenience_methods/worksheet.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 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 before_write_xml has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

                  def before_write_xml
                    content_types_by_ext = {}
              
                    # Collect all extensions and corresponding content types
                    root.rels_hash.each_pair { |klass, objects|
              Severity: Minor
              Found in lib/rubyXL/objects/content_types.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

              File ooxml_object.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'nokogiri'
              require 'pathname'
              require 'rubyXL/objects/reference'
              
              module RubyXL
              Severity: Minor
              Found in lib/rubyXL/objects/ooxml_object.rb - About 2 hrs to fix

                Method add_cell has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def add_cell(row_index = 0, column_index = 0, data = '', formula = nil, overwrite = true)
                      validate_workbook
                      validate_nonnegative(row_index)
                      validate_nonnegative(column_index)
                      row = sheet_data.rows[row_index] || add_row(row_index)
                Severity: Minor
                Found in lib/rubyXL/worksheet.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

                Method load_related_files has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def load_related_files(zipdir_path, base_file_name)
                      self.related_files = {}
                
                      @@debug_indent += 2 if @@debug_indent
                
                
                Severity: Minor
                Found in lib/rubyXL/objects/relationships.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

                Method parse has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def parse(node, known_namespaces = nil)
                      case node
                      when String, IO, Zip::InputStream then node = Nokogiri::XML.parse(node)
                      end
                
                
                Severity: Minor
                Found in lib/rubyXL/objects/ooxml_object.rb - About 2 hrs to fix

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

                      def delete_cell(row_index = 0, column_index=0, shift=nil)
                        validate_workbook
                        validate_nonnegative(row_index)
                        validate_nonnegative(column_index)
                  
                  
                  Severity: Minor
                  Found in lib/rubyXL/convenience_methods/worksheet.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

                  Severity
                  Category
                  Status
                  Source
                  Language