relaton/relaton-itu

View on GitHub

Showing 10 of 10 total issues

Method params has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def params # rubocop:disable Metrics/MethodLength
      input = @refid.dup
      input.year = nil
      {
        "Input" => input.to_s,
Severity: Minor
Found in lib/relaton_itu/hit_collection.rb - About 1 hr to fix

    Method parse_page has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def parse_page(hit, imp: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
            doc = get_page hit
            return unless doc.code == "200"
    
            if imp
    Severity: Minor
    Found in lib/relaton_itu/scrapper.rb - About 1 hr to fix

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

          def initialize(bureau:, group:, subgroup: nil, workgroup: nil)
            unless BUREAUS.include? bureau
              Util.warn "WARNING: Invalid bureau: `#{bureau}`"
              Util.warn "WARNING: Valid bureaus are: `#{BUREAUS.join('`, `')}`"
            end
      Severity: Minor
      Found in lib/relaton_itu/editorial_group.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 roman_to_2digit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def roman_to_2digit(num) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
            return unless num
      
            roman_nums = { "I" => 1, "V" => 5, "X" => 10 }
            last = roman_nums[num[-1]]
      Severity: Minor
      Found in lib/relaton_itu/pubid.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 fetch_abstract has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def fetch_abstract(doc, hit) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
              abstract_url = doc.at '//table/tr[td/span[.="In force"]]/td/span[contains(@id, "lbl_dms")]/div'
              content = if abstract_url
                          url = abstract_url[:onclick].match(/https?[^']+/).to_s
                          rsp = hit.hit_collection.agent.get url
      Severity: Minor
      Found in lib/relaton_itu/scrapper.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 to_h has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_h(with_type: true) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
            hash = { prefix: prefix, sector: sector, code: code }
            hash[:type] = type if type && with_type
            hash[:suppl] = suppl if suppl
            hash[:annex] = annex if annex
      Severity: Minor
      Found in lib/relaton_itu/pubid.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 to_xml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_xml(builder) # rubocop:disable Metrics/AbcSize
            builder.editorialgroup do
              builder.bureau bureau
              builder.group { |b| group.to_xml b } if group
              builder.subgroup { |b| group.to_xml b } if subgroup
      Severity: Minor
      Found in lib/relaton_itu/editorial_group.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get(code, year = nil, opts = {}) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
            refid = Pubid.parse code
            refid.year ||= year
            # if year.nil?
            #   /^(?<code1>[^\s]+\s[^\s]+)\s\((?:\d{2}\/)?(?<year1>\d+)\)$/ =~ code
      Severity: Minor
      Found in lib/relaton_itu/itu_bibliography.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 isobib_results_filter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def isobib_results_filter(result, refid)
            missed_years = []
            result.each do |r|
              /\((?:\d{2}\/)?(?<pyear>\d{4})\)/ =~ r.hit[:code]
              if !refid.year || refid.year == pyear
      Severity: Minor
      Found in lib/relaton_itu/itu_bibliography.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 parse_page has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_page(hit, imp: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
              doc = get_page hit
              return unless doc.code == "200"
      
              if imp
      Severity: Minor
      Found in lib/relaton_itu/scrapper.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