Showing 40 of 40 total issues

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

    def title(content=UNASSIGNED, id: nil, title_type: nil)
      if unassigned?(content)
        if !@content_nodes['title'].nil?
          @content_nodes['title'].each do
            |titlenode|
Severity: Minor
Found in lib/gepub/metadata.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 write_to_epub_container has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def write_to_epub_container(epub)
      mod_time = Zip::DOSTime.now
      unless (last_mod = lastmodified).nil?
        tm = last_mod.content
        mod_time = Zip::DOSTime.local(tm.year, tm.month, tm.day, tm.hour, tm.min, tm.sec)
Severity: Minor
Found in lib/gepub/book.rb - About 1 hr to fix

    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 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 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 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 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 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/datemeta.rb - About 35 mins to fix

          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(name, content, parent, attributes= {}, refiners = {})
            Severity: Minor
            Found in lib/gepub/meta.rb - About 35 mins to fix

              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 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

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

                      methodbase = name.gsub('-','_')
                      define_method(methodbase + '=') { |val| @attributes[name] = val }
                      define_method('set_' + methodbase) { |val| @attributes[name] = val }
                      define_method(methodbase) { @attributes[name] }
              Severity: Minor
              Found in lib/gepub/spine.rb and 1 other location - About 30 mins to fix
              lib/gepub/spine.rb on lines 116..119

              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 32.

              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

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

                    methodbase = name.gsub('-','_')
                    define_method(methodbase + '=') { |val| @attributes[name] = val }
                    define_method('set_' + methodbase) { |val| @attributes[name] = val }
                    define_method(methodbase) { @attributes[name] }
              Severity: Minor
              Found in lib/gepub/spine.rb and 1 other location - About 30 mins to fix
              lib/gepub/spine.rb on lines 25..28

              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 32.

              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 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

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

                  def add_item(href, deprecated_content = nil, deprecated_id = nil, deprecated_attributes = nil, content: nil, 
                               id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,property: nil,
                               attributes: {})
              Severity: Minor
              Found in lib/gepub/book_add_item.rb and 1 other location - About 15 mins to fix
              lib/gepub/book_add_item.rb on lines 15..17

              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 25.

              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

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

                  def add_ordered_item(href, deprecated_content = nil, deprecated_id = nil, deprecated_attributes = nil,  content:nil,
                                       id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,property: nil,
                                       attributes: {})
              Severity: Minor
              Found in lib/gepub/book_add_item.rb and 1 other location - About 15 mins to fix
              lib/gepub/book_add_item.rb on lines 7..9

              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 25.

              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

              Severity
              Category
              Status
              Source
              Language