lib/gepub/metadata.rb

Summary

Maintainability
C
1 day
Test Coverage
A
92%

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

        There are no issues that match your filters.

        Category
        Status