relaton/relaton-ietf

View on GitHub

Showing 12 of 12 total issues

Class RfcEntry has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class RfcEntry
    #
    # Initalize parser
    #
    # @param [Nokogiri::XML::Element] doc document
Severity: Minor
Found in lib/relaton_ietf/rfc_entry.rb - About 2 hrs to fix

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

        def update_versions(versions) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
          series = ""
          bib_versions = []
          Dir["#{@output}/*.#{@ext}"].each do |file|
            match = /(?<series>draft-.+)-(?<ver>\d{2})\.#{@ext}$/.match file
    Severity: Minor
    Found in lib/relaton_ietf/data_fetcher.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 to_xml has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
          opts[:date_format] ||= :short
          super(**opts) do |builder|
            if opts[:bibdata] && (doctype || editorialgroup || ics&.any? ||
              structuredidentifier&.presence? || stream)
    Severity: Minor
    Found in lib/relaton_ietf/ietf_bibliographic_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

    Method full_name_org has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def full_name_org(name) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
          case name
          when "ISO"
            RelatonBib::Organization.new(abbreviation: name, name: "International Organization for Standardization")
          when "IAB"
    Severity: Minor
    Found in lib/relaton_ietf/bibxml_parser.rb - About 1 hr to fix

      Method render_authors has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def render_authors(builder) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
              @bib.contributor.each do |c|
                next if c.entity.is_a?(RelatonBib::Organization) && c.entity.name.map(&:content).include?("RFC Publisher")
      
                builder.author do |xml|
      Severity: Minor
      Found in lib/relaton_ietf/renderer/bibxml.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

      Consider simplifying this complex logical expression.
      Open

              if opts[:bibdata] && (doctype || editorialgroup || ics&.any? ||
                structuredidentifier&.presence? || stream)
                ext = builder.ext do |b|
                  doctype&.to_xml b
                  b.subdoctype subdoctype if subdoctype
      Severity: Major
      Found in lib/relaton_ietf/ietf_bibliographic_item.rb - About 40 mins to fix

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

            def full_name(fname, sname, inits, lang, script = nil)
        Severity: Minor
        Found in lib/relaton_ietf/bibxml_parser.rb - About 35 mins to fix

          Method save_doc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def save_doc(entry, check_duplicate: true) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
                return unless entry
          
                c = case @format
                    when "xml" then entry.to_xml(bibdata: true)
          Severity: Minor
          Found in lib/relaton_ietf/data_fetcher.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 fetch_ieft_internet_drafts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def fetch_ieft_internet_drafts # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
                versions = Dir["bibxml-ids/*.xml"].each_with_object([]) do |path, vers|
                  file = File.basename path, ".xml"
                  if file.include?("D.draft-")
                    vers << file.sub(/^reference\.I-D\./, "").downcase
          Severity: Minor
          Found in lib/relaton_ietf/data_fetcher.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

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

              def get_rfcsubseries(ref)
                index = Relaton::Index.find_or_create :RSS, url: "#{RSS}index-v1.zip", file: INDEX_FILE
                row = index.search(ref).first
                get_page "#{RSS}#{row[:file]}" if row
          Severity: Minor
          Found in lib/relaton_ietf/scrapper.rb and 2 other locations - About 25 mins to fix
          lib/relaton_ietf/scrapper.rb on lines 40..43
          lib/relaton_ietf/scrapper.rb on lines 52..55

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

          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 3 locations. Consider refactoring.
          Open

              def get_ids(ref)
                index = Relaton::Index.find_or_create :IDS, url: "#{IDS}index-v1.zip", file: INDEX_FILE
                row = index.search(ref).first
                get_page "#{IDS}#{row[:file]}" if row
          Severity: Minor
          Found in lib/relaton_ietf/scrapper.rb and 2 other locations - About 25 mins to fix
          lib/relaton_ietf/scrapper.rb on lines 40..43
          lib/relaton_ietf/scrapper.rb on lines 46..49

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

          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 3 locations. Consider refactoring.
          Open

              def get_rfcs(ref)
                index = Relaton::Index.find_or_create :RFC, url: "#{RFC}index-v1.zip", file: INDEX_FILE
                row = index.search(ref).first
                get_page "#{RFC}#{row[:file]}" if row
          Severity: Minor
          Found in lib/relaton_ietf/scrapper.rb and 2 other locations - About 25 mins to fix
          lib/relaton_ietf/scrapper.rb on lines 46..49
          lib/relaton_ietf/scrapper.rb on lines 52..55

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

          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