relaton/relaton-cen

View on GitHub

Showing 7 of 7 total issues

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

    def initialize(ref, year = nil) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
      super ref, year
      @agent = Mechanize.new
      agent.user_agent_alias = "Mac Safari"
      if !ref || ref.empty?
Severity: Minor
Found in lib/relaton_cen/hit_collection.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 initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(ref, year = nil) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
      super ref, year
      @agent = Mechanize.new
      agent.user_agent_alias = "Mac Safari"
      if !ref || ref.empty?
Severity: Minor
Found in lib/relaton_cen/hit_collection.rb - About 1 hr to fix

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

        def sort
          @array.sort! do |a, b|
            ap = CenBibliography.code_to_parts a.hit[:code]
            bp = CenBibliography.code_to_parts b.hit[:code]
            s = ap[:code] <=> bp[:code]
    Severity: Minor
    Found in lib/relaton_cen/hit_collection.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 bib_get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def bib_get(code, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
            ref = year.nil? || code.match?(/:\d{4}/) ? code : "#{code}:#{year}"
            Util.info "Fetching from standards.cencenelec.eu ...", key: ref
            result = search_filter(code) || return
            ret = isobib_results_filter(result, year)
    Severity: Minor
    Found in lib/relaton_cen/cen_bibliography.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_editorialgroup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def fetch_editorialgroup(doc) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
            code = doc.at("//tr/td/h1/text()").text
            title = doc.at("//tr/td[3]/h1").text
            %r{/(?<type>\w+)(?:\s(?<num>[^/]+))?$} =~ code
            tc = []
    Severity: Minor
    Found in lib/relaton_cen/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

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

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

          def search_filter(code) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
            parts = code_to_parts code
            result = search(code)
            result.select do |i|
              pts = code_to_parts i.hit[:code]
    Severity: Minor
    Found in lib/relaton_cen/cen_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

    Severity
    Category
    Status
    Source
    Language