ifduyue/npm-mirror

View on GitHub

Showing 9 of 9 total issues

Method tarball_links has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def tarball_links(json)
        json.each do |_, v|
          next unless v.is_a? Hash
          if v['shasum'] && v['tarball']
            if v['tarball'].start_with?(@from)
Severity: Minor
Found in lib/npm/mirror.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 fetch_index has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def fetch_index
        url = from '-/all'
        path = to '-/all/index.json'
        resp = fetch url, path
        fail Error, "Failed to fetch #{url}" if resp.nil?
Severity: Minor
Found in lib/npm/mirror.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 fetch has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def fetch(url, path = nil)
        uri = URI url
        etag = etag_for path

        req = Net::HTTP::Get.new uri.path
Severity: Minor
Found in lib/npm/mirror.rb - About 1 hr to fix

    Method fetch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def fetch(url, path = nil)
            uri = URI url
            etag = etag_for path
    
            req = Net::HTTP::Get.new uri.path
    Severity: Minor
    Found in lib/npm/mirror.rb - About 55 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 correct_tarball_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def correct_tarball_url
            Dir.glob("#{to}/*/index.json").each do |filename|
              json = JSON.load(File.open(filename, 'rb').read)
              next unless json['versions']
              versions = json['versions'].keys
    Severity: Minor
    Found in lib/npm/mirror.rb - About 55 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def initialize(from = DEFAULT_FROM, to = DEFAULT_TO,
                         server = DEFAULT_SERVER, parallelism = 10,
                         recheck = false)
    Severity: Minor
    Found in lib/npm/mirror.rb - About 35 mins to fix

      Avoid too many return statements within this method.
      Open

                return resp
      Severity: Major
      Found in lib/npm/mirror.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return nil
        Severity: Major
        Found in lib/npm/mirror.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return nil
          Severity: Major
          Found in lib/npm/mirror.rb - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language