Showing 34 of 40 total issues

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

    def add_item_internal(href, content: nil, item_attributes: , attributes: {}, ordered: )
      id = item_attributes.delete(:id)
      item = 
        if ordered
          @package.add_ordered_item(href,attributes: attributes, id:id, content: content)
Severity: Minor
Found in lib/gepub/book.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 handle_deprecated_add_item_arguments has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_deprecated_add_item_arguments(deprecated_content, deprecated_id, deprecated_attributes, content, id, attributes) 
      if deprecated_content
        msg = 'deprecated argument; use content keyword argument instead of 2nd argument' 
        fail msg if content
        warn msg
Severity: Minor
Found in lib/gepub/book.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 parse_container has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def self.parse_container(zip_file, files) 
      package_path = nil
      package = nil
      zip_file.each do |entry|
        if !entry.directory?
Severity: Minor
Found in lib/gepub/book.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 handle_deprecated_add_item_arguments has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def handle_deprecated_add_item_arguments(deprecated_content, deprecated_id, deprecated_attributes, content, id, attributes) 
Severity: Minor
Found in lib/gepub/book.rb - About 45 mins to fix

    Method cleanup_for_epub2 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def  cleanup_for_epub2
          if version.to_f < 3.0 || @package.epub_backward_compat
            if @package.manifest.item_list.select {
              |_x,item|
              item.media_type == 'application/x-dtbncx+xml'
    Severity: Minor
    Found in lib/gepub/book.rb - About 45 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 generate_key has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def generate_key(param = {})
            prefix = param[:prefix] || ''
            suffix = param[:suffix] || ''
            count = [ param[:start] || 1, counter(prefix,suffix) || 1].max
            while (true)
    Severity: Minor
    Found in lib/gepub/package.rb - About 45 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 to_xml has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def to_xml(builder, id_pool, ns = nil, additional_attr = {}, opf_version = '3.0')
    Severity: Minor
    Found in lib/gepub/meta.rb - About 35 mins to fix

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

          def initialize(itemid, itemhref, itemmediatype = nil, parent = nil, attributes = {})
      Severity: Minor
      Found in lib/gepub/item.rb - About 35 mins to fix

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

            def initialize(name, content, parent, attributes= {}, refiners = {})
        Severity: Minor
        Found in lib/gepub/meta.rb - About 35 mins to fix

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

              def initialize(name, content, parent, attributes = {}, refiners = {})
          Severity: Minor
          Found in lib/gepub/datemeta.rb - About 35 mins to fix

            Method cleanup_for_epub3 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def cleanup_for_epub3
                  if version.to_f >=3.0
                    @package.metadata.modified_now unless @package.metadata.lastmodified_updated?
                    
                    if @package.manifest.item_list.select {
            Severity: Minor
            Found in lib/gepub/book.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 ncx_xml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def ncx_xml
                  builder = Nokogiri::XML::Builder.new {
                    |xml|
                    xml.ncx('xmlns' => 'http://www.daisy.org/z3986/2005/ncx/', 'version' => '2005-1') {
                      xml.head {
            Severity: Minor
            Found in lib/gepub/book.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize(path='OEBPS/package.opf', attributes={})
                  @path = path
                  if File.extname(@path) != '.opf'
                    if @path.size > 0
                      @path = [path,'package.opf'].join('/')
            Severity: Minor
            Found in lib/gepub/package.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 inspect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def inspect
                  result = instance_variables.each
                    .with_object({}) { |name, h| h[name] = instance_variable_get(name) }
                    .reject { |name, value| value.nil? }
                    .map { |name, value|
            Severity: Minor
            Found in lib/gepub/inspect_mixin.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