sergicastro/manage-credentials

View on GitHub

Showing 217 of 217 total issues

Assignment Branch Condition size for send_request is too high. [36.62/15]
Open

    def send_request(request)
        uri = URI.parse(@conf.location)
        http = Net::HTTP.new(uri.host, uri.port)
        if @use_ssl
            http.use_ssl = true
Severity: Minor
Found in lib/api_client.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [24/10]
Open

    def send_request(request)
        uri = URI.parse(@conf.location)
        http = Net::HTTP.new(uri.host, uri.port)
        if @use_ssl
            http.use_ssl = true
Severity: Minor
Found in lib/api_client.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for add is too high. [19.34/15]
Open

    def add(provider, enterprise)
        raise Exception.new("Provider #{provider} not found in configuration file") if @conf.conf[provider].nil?

        key = @conf.conf[provider]['key']
        access = @conf.conf[provider]['id']
Severity: Minor
Found in lib/business_service.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for get_enterprise_id is too high. [19.52/15]
Open

    def get_enterprise_id(enterprise_name)
        request = Net::HTTP::Get.new("#{@conf.location}/admin/enterprises")
        request.add_field('accept', 'application/vnd.abiquo.enterprises+json')
        puts "Searching for enterprise #{enterprise_name}..."
        response = send_request(request)
Severity: Minor
Found in lib/api_client.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for delete_credentials is too high. [19.44/15]
Open

    def delete_credentials(provider, enterprise)
        credentials = get_credentials(enterprise)
        coll = JSON.parse(credentials)["collection"]
        links = coll.collect{ |x| x["links"] }
        creds = links[0].select{ |link| link["rel"] == "edit" }[0]
Severity: Minor
Found in lib/api_client.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for list_credentials is too high. [18.22/15]
Open

    def list_credentials(enterprise)
        links = JSON.parse(get_credentials(enterprise))["collection"].collect{ |cred| cred["links"] }.zip
        if not links.nil? and not links[0].nil?
            match = links[0][0].select{ |link| link["rel"] == "hypervisortype" }
            return match.collect{ |link| link["title"] }
Severity: Minor
Found in lib/api_client.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for get_technology_link is too high. [17.72/15]
Open

    def get_technology_link(provider)
        request = Net::HTTP::Get.new("#{@conf.location}/config/hypervisortypes")
        request.add_field('accept','application/vnd.abiquo.hypervisortypes+json')
        puts "Searching for provider #{provider}..."
        response = send_request(request)
Severity: Minor
Found in lib/api_client.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [11/10]
Open

    def search_iterate(key_to_match, value_to_set, k, v, i)
        if k == key_to_match[i]
            if not v.nil? and v.is_a?(Hash)
                v.each do |k1, v1|
                    if search_iterate(key_to_match, value_to_set, k1, v1, i+1)
Severity: Minor
Found in lib/conf.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

    def search_iterate(key_to_match, value_to_set, k, v, i)
        if k == key_to_match[i]
            if not v.nil? and v.is_a?(Hash)
                v.each do |k1, v1|
                    if search_iterate(key_to_match, value_to_set, k1, v1, i+1)
Severity: Minor
Found in lib/conf.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 search_iterate has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def search_iterate(key_to_match, value_to_set, k, v, i)
Severity: Minor
Found in lib/conf.rb - About 35 mins to fix

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

        def send_request(request)
            uri = URI.parse(@conf.location)
            http = Net::HTTP.new(uri.host, uri.port)
            if @use_ssl
                http.use_ssl = true
    Severity: Minor
    Found in lib/api_client.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

    Missing magic comment # frozen_string_literal: true.
    Open

    require 'rake/testtask'
    Severity: Minor
    Found in Rakefile by rubocop

    This cop is designed to help upgrade to Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

    Example: EnforcedStyle: when_needed (default)

    # The `when_needed` style will add the frozen string literal comment
    # to files only when the `TargetRubyVersion` is set to 2.3+.
    # bad
    module Foo
      # ...
    end
    
    # good
    # frozen_string_literal: true
    
    module Foo
      # ...
    end

    Example: EnforcedStyle: always

    # The `always` style will always add the frozen string literal comment
    # to a file, regardless of the Ruby version or if `freeze` or `<<` are
    # called on a string literal.
    # bad
    module Bar
      # ...
    end
    
    # good
    # frozen_string_literal: true
    
    module Bar
      # ...
    end

    Example: EnforcedStyle: never

    # The `never` will enforce that the frozen string literal comment does
    # not exist in a file.
    # bad
    # frozen_string_literal: true
    
    module Baz
      # ...
    end
    
    # good
    module Baz
      # ...
    end

    Use 2 (not 4) spaces for indentation.
    Open

            puts "#{@client.delete_credentials(provider, enterprise)}".colorize(:green)
    Severity: Minor
    Found in lib/business_service.rb by rubocop

    This cops checks for indentation that doesn't use the specified number of spaces.

    See also the IndentationConsistency cop which is the companion to this one.

    Example:

    # bad
    class A
     def test
      puts 'hello'
     end
    end
    
    # good
    class A
      def test
        puts 'hello'
      end
    end

    Example: IgnoredPatterns: ['^\s*module']

    # bad
    module A
    class B
      def test
      puts 'hello'
      end
    end
    end
    
    # good
    module A
    class B
      def test
        puts 'hello'
      end
    end
    end

    Prefer single-quoted strings inside interpolations.
    Open

                puts "id", "#{@conf.conf[provider]["id"]}".colorize(:cyan)
    Severity: Minor
    Found in lib/business_service.rb by rubocop

    This cop checks that quotes inside the string interpolation match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    result = "Tests #{success ? "PASS" : "FAIL"}"
    
    # good
    result = "Tests #{success ? 'PASS' : 'FAIL'}"

    Example: EnforcedStyle: double_quotes

    # bad
    result = "Tests #{success ? 'PASS' : 'FAIL'}"
    
    # good
    result = "Tests #{success ? "PASS" : "FAIL"}"

    Use 2 (not 4) spaces for indentation.
    Open

            BusinessService.new(@@conf).show_location
    Severity: Minor
    Found in lib/manage_credentials.rb by rubocop

    This cops checks for indentation that doesn't use the specified number of spaces.

    See also the IndentationConsistency cop which is the companion to this one.

    Example:

    # bad
    class A
     def test
      puts 'hello'
     end
    end
    
    # good
    class A
      def test
        puts 'hello'
      end
    end

    Example: IgnoredPatterns: ['^\s*module']

    # bad
    module A
    class B
      def test
      puts 'hello'
      end
    end
    end
    
    # good
    module A
    class B
      def test
        puts 'hello'
      end
    end
    end

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

        desc "list_providers [remote]", "Lists the config file providers. --remote option will list the remote ones"
    Severity: Minor
    Found in lib/manage_credentials.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

        desc "set_location <new_location>", "Sets the new api location"
    Severity: Minor
    Found in lib/manage_credentials.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Space missing after comma.
    Open

            @conf.each do |k,v|
    Severity: Minor
    Found in lib/conf.rb by rubocop

    Checks for comma (,) not followed by some kind of space.

    Example:

    # bad
    [1,2]
    { foo:bar,}
    
    # good
    [1, 2]
    { foo:bar, }

    Use 2 (not 4) spaces for indentation.
    Open

        def initialize(conf)
    Severity: Minor
    Found in lib/api_client.rb by rubocop

    This cops checks for indentation that doesn't use the specified number of spaces.

    See also the IndentationConsistency cop which is the companion to this one.

    Example:

    # bad
    class A
     def test
      puts 'hello'
     end
    end
    
    # good
    class A
      def test
        puts 'hello'
      end
    end

    Example: IgnoredPatterns: ['^\s*module']

    # bad
    module A
    class B
      def test
      puts 'hello'
      end
    end
    end
    
    # good
    module A
    class B
      def test
        puts 'hello'
      end
    end
    end

    Use 2 (not 4) spaces for indentation.
    Open

            @conf = conf
    Severity: Minor
    Found in lib/api_client.rb by rubocop

    This cops checks for indentation that doesn't use the specified number of spaces.

    See also the IndentationConsistency cop which is the companion to this one.

    Example:

    # bad
    class A
     def test
      puts 'hello'
     end
    end
    
    # good
    class A
      def test
        puts 'hello'
      end
    end

    Example: IgnoredPatterns: ['^\s*module']

    # bad
    module A
    class B
      def test
      puts 'hello'
      end
    end
    end
    
    # good
    module A
    class B
      def test
        puts 'hello'
      end
    end
    end
    Severity
    Category
    Status
    Source
    Language