ashrithr/awscli

View on GitHub

Showing 134 of 134 total issues

File ec2.rb has 781 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Awscli
  module EC2
    require 'pp'

    class EC2
Severity: Major
Found in lib/awscli/ec2.rb - About 1 day to fix

    Method create_job_flow has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

          def create_job_flow(options)
            # => BOOTSTRAP ACTIONS
            boot_strap_actions = []
            if options[:bootstrap_actions]
              options[:bootstrap_actions].each do |step|
    Severity: Minor
    Found in lib/awscli/emr.rb - About 1 day 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 create_instance has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

          def create_instance(options)
            #validate required options
            puts 'Validating Options ...'
            abort "Invalid Key: #{options[:key_name]}" unless @conn.key_pairs.get(options[:key_name])
            options[:groups].each do |sg|
    Severity: Minor
    Found in lib/awscli/ec2.rb - About 7 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

    File emr.rb has 423 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Awscli
      module Emr
        class EMR
          def initialize(connection)
            @conn = connection
    Severity: Minor
    Found in lib/awscli/emr.rb - About 6 hrs to fix

      Method delete has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

            def delete(options)
              username = options[:user_name]
              user = @conn.users.get(username)
              if user
                if options[:force]
      Severity: Minor
      Found in lib/awscli/iam.rb - About 5 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 update has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

            def update(options)
              opts = {}
              key = {}
              attribute_updates = {}
              #Build and validate key
      Severity: Minor
      Found in lib/awscli/dynamo.rb - About 5 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 create has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

            def create(options)
              #validate block device mapping and parse it to a hash understandable by fog
              opts = Marshal.load(Marshal.dump(options))
              block_device_mapping = Array.new
              if options[:block_device_mappings]
      Severity: Minor
      Found in lib/awscli/as.rb - About 5 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 put has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

            def put(options)
              items = {}
              opts = {}
              options[:item].each do |item|
                abort "invalid item format: #{item}" unless item =~ /(.*):(N|S|NS|SS|B|BS):(.*)/
      Severity: Minor
      Found in lib/awscli/dynamo.rb - About 5 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

      File dynamo.rb has 390 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Awscli
        module DynamoDB
          class Table
            def initialize(connection)
              @conn = connection
      Severity: Minor
      Found in lib/awscli/dynamo.rb - About 5 hrs to fix

        Method delete has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

              def delete(options)
                key = {}
                opts = {}
                #Build and validate key
                abort 'Invalid --hash-key format' unless options[:hash_key] =~ /(N|S|NS|SS|B|BS):(.*)/
        Severity: Minor
        Found in lib/awscli/dynamo.rb - About 5 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

        File iam.rb has 371 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'json'
        
        module Awscli
          module Iam
        
        
        Severity: Minor
        Found in lib/awscli/iam.rb - About 4 hrs to fix

          Method delete_rec has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

                def delete_rec(dir_name)
                  #Forked from https://gist.github.com/bdunagan/1383301
                  data_queue = Queue.new
                  semaphore = Mutex.new
                  threads = Array.new
          Severity: Minor
          Found in lib/awscli/s3.rb - About 3 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 create_job_flow has 89 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def create_job_flow(options)
                  # => BOOTSTRAP ACTIONS
                  boot_strap_actions = []
                  if options[:bootstrap_actions]
                    options[:bootstrap_actions].each do |step|
          Severity: Major
          Found in lib/awscli/emr.rb - About 3 hrs to fix

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

                    if options[:block_device_mappings]
                      options[:block_device_mappings].each do |group|
                        mapping = Hash.new
                        #parse options
                        abort "Invalid block device mapping format, expecting 'devicename=blockdevice' format" unless group =~ /\S=\S/
            Severity: Major
            Found in lib/awscli/as.rb and 1 other location - About 3 hrs to fix
            lib/awscli/ec2.rb on lines 101..124

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

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

                    if options[:block_device_mapping]
                      options[:block_device_mapping].each do |group|
                        mapping = Hash.new
                        #parse options
                        abort "Invalid block device mapping format, expecting 'devicename=blockdevice' format" unless group =~ /\S=\S/
            Severity: Major
            Found in lib/awscli/ec2.rb and 1 other location - About 3 hrs to fix
            lib/awscli/as.rb on lines 35..57

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

            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

            Method query has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                  def query(options)
                    opts = {}
                    hash_key_type, hash_key_value = options[:hash_key_value].split(',')
                    hash_key = { hash_key_type => hash_key_value }
                    opts['AttributesToGet'] = options[:attrs_to_get] if options[:attrs_to_get]
            Severity: Minor
            Found in lib/awscli/dynamo.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 query has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                    def query
                      unless options[:table_name] and options[:hash_key_value]
                        abort 'options --table-name and --hash-key-value are required'
                      end
                      abort 'invalid --hash-key-value format' unless options[:hash_key_value] =~ /^(.*?),(.*?)$/
            Severity: Minor
            Found in lib/awscli/cli/dynamo/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 scan has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                  def scan(options)
                    opts = {}
                    opts['AttributesToGet'] = options[:attrs_to_get] if options[:attrs_to_get]
                    opts['Limit'] = options[:limit] if options[:limit]
                    opts['ConsistentRead'] = options[:consistent_read] if options[:consistent_read]
            Severity: Minor
            Found in lib/awscli/dynamo.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

            Class EMR has 24 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class EMR
                  def initialize(connection)
                    @conn = connection
                  end
            
            
            Severity: Minor
            Found in lib/awscli/emr.rb - About 2 hrs to fix

              Method create_instance has 66 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def create_instance(options)
                      #validate required options
                      puts 'Validating Options ...'
                      abort "Invalid Key: #{options[:key_name]}" unless @conn.key_pairs.get(options[:key_name])
                      options[:groups].each do |sg|
              Severity: Major
              Found in lib/awscli/ec2.rb - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language