Showing 34 of 40 total issues

Class Metadata has 39 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Metadata
    class NilContent
      def self.content
        nil
      end
Severity: Minor
Found in lib/gepub/metadata.rb - About 5 hrs to fix

    File book.rb has 376 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rubygems'
    require 'nokogiri'
    require 'zip'
    require 'fileutils'
    
    
    Severity: Minor
    Found in lib/gepub/book.rb - About 5 hrs to fix

      Method nav_doc has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def nav_doc(title = 'Table of Contents')
            # handle cascaded toc
            start_level = @toc && !@toc.empty? && @toc[0][:level] || 1
            stacked_toc = {level: start_level, tocs: [] }
            @toc.inject(stacked_toc) do |current_stack, toc_entry|
      Severity: Minor
      Found in lib/gepub/book.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 nav_doc has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def nav_doc(title = 'Table of Contents')
            # handle cascaded toc
            start_level = @toc && !@toc.empty? && @toc[0][:level] || 1
            stacked_toc = {level: start_level, tocs: [] }
            @toc.inject(stacked_toc) do |current_stack, toc_entry|
      Severity: Major
      Found in lib/gepub/book.rb - About 2 hrs to fix

        Class Book has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Book
            include InspectMixin
        
            MIMETYPE='mimetype'
            MIMETYPE_CONTENTS='application/epub+zip'
        Severity: Minor
        Found in lib/gepub/book.rb - About 2 hrs to fix

          File metadata.rb has 282 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'rubygems'
          require 'nokogiri'
          require 'time'
          
          module GEPUB
          Severity: Minor
          Found in lib/gepub/metadata.rb - About 2 hrs to fix

            Method guess_content_property has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                def guess_content_property
                  if File.extname(self.href) =~ /.x?html/ && @attributes['media-type'] === 'application/xhtml+xml'
                    @attributes['properties'] ||= []
                    parsed = Nokogiri::XML::Document.parse(@content)
                    return unless parsed.root.node_name === "html"
            Severity: Minor
            Found in lib/gepub/item.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

            Class ResourceBuilder has 23 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class ResourceBuilder
                include BuilderMixin
                class ResourceItem
                  attr_reader :item
                  def initialize(item)
            Severity: Minor
            Found in lib/gepub/resource_builder.rb - About 2 hrs to fix

              Class Package has 21 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Package
                  include XMLUtil, DSLUtil
                  include InspectMixin
              
                  extend Forwardable
              Severity: Minor
              Found in lib/gepub/package.rb - About 2 hrs to fix

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

                    def opf_xml
                      if version.to_f < 3.0 || @epub_backward_compat
                        spine.toc  ||= 'ncx'
                        if @metadata.oldstyle_meta.select {
                          |meta|
                Severity: Minor
                Found in lib/gepub/package.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 write_toc has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                      def write_toc xml_doc, tocs
                        return if tocs.empty?
                        xml_doc.ol {
                          tocs.each {
                            |x|
                Severity: Minor
                Found in lib/gepub/book.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 lastmodified has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def lastmodified(date=UNASSIGNED)
                      if unassigned?(date)
                        ret = (@content_nodes['meta'] ||=[]).select {
                          |meta|
                          meta['property'] == 'dcterms:modified'
                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 method_missing has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def method_missing(name, *args, &block)
                      if Array === @last_defined_item &&
                          @last_defined_item.size > 0 &&
                          @last_defined_item[0].respond_to?(name.to_sym)
                
                
                Severity: Minor
                Found in lib/gepub/builder_mixin.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 to_xml has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def to_xml(builder, id_pool, ns = nil, additional_attr = {}, opf_version = '3.0')
                      additional_attr ||= {}
                      if @refiners.size > 0 && opf_version.to_f >= 3.0
                        @attributes['id'] = id_pool.generate_key(:prefix => name) if @attributes['id'].nil?
                      end
                Severity: Minor
                Found in lib/gepub/meta.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 opf_xml has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def opf_xml
                      if version.to_f < 3.0 || @epub_backward_compat
                        spine.toc  ||= 'ncx'
                        if @metadata.oldstyle_meta.select {
                          |meta|
                Severity: Minor
                Found in lib/gepub/package.rb - About 1 hr to fix

                  Method ncx_xml has 32 lines of code (exceeds 25 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 1 hr to fix

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

                        def self.parse(metadata_xml, opf_version = '3.0', id_pool = Package::IDPool.new)
                          Metadata.new(opf_version, id_pool) {
                            |metadata|
                            metadata.instance_eval {
                              @xml = metadata_xml
                    Severity: Minor
                    Found in lib/gepub/metadata.rb - About 1 hr to fix

                      Method guess_content_property has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def guess_content_property
                            if File.extname(self.href) =~ /.x?html/ && @attributes['media-type'] === 'application/xhtml+xml'
                              @attributes['properties'] ||= []
                              parsed = Nokogiri::XML::Document.parse(@content)
                              return unless parsed.root.node_name === "html"
                      Severity: Minor
                      Found in lib/gepub/item.rb - About 1 hr to fix

                        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
                          Severity
                          Category
                          Status
                          Source
                          Language