ashrithr/awscli

View on GitHub

Showing 134 of 134 total issues

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

      def create(options)
        key_schema, provisioned_throughput = {}, {}
        abort 'Invalid key type' unless %w(N NS S SS).include?(options[:pk_type])
        key_schema['HashKeyElement'] = {
          'AttributeName' => options[:pk_name],
Severity: Minor
Found in lib/awscli/dynamo.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 batch_get has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def batch_get(options)
        request_items = {}
        map = options[:requests].zip(options[:attrs_to_get])
        map.each do |request_attrs_mapping|
          #tbl1_name*,KeySet1(hash_key_type*=hash_key_value*:range_key_type=range_key_value),KeySet2,KeySetN
Severity: Minor
Found in lib/awscli/dynamo.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 put has 43 lines of code (exceeds 25 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 1 hr to fix

    Method delete has 40 lines of code (exceeds 25 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 1 hr to fix

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

            def upload_file_rec(options)
              dir_name, dir_path, threads_count, is_public = options[:bucket_name], options[:dir_path], options[:thread_count], options[:public]
              dest_path = options[:dest_path] if options[:dest_path]
              #check if bucket exists
              bucket = @conn.directories.get(dir_name)
      Severity: Minor
      Found in lib/awscli/s3.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 multipart_upload has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def multipart_upload(options)
              bucket_name, file_path, tmp_loc, acl = options[:bucket_name], options[:file_path], options[:tmp_dir], options[:acl]
              dir = @conn.directories.get(bucket_name)
              abort "cannot find bucket: #{bucket_name}" unless dir
              file = File.expand_path(file_path)
      Severity: Minor
      Found in lib/awscli/s3.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 query has 38 lines of code (exceeds 25 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 1 hr to fix

        Method delete has 37 lines of code (exceeds 25 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 1 hr to fix

          Method scan has 36 lines of code (exceeds 25 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 1 hr to fix

            Method parse_instance_groups has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse_instance_groups(groups)
                    #parse instance_groups => instance_count,instance_role(MASTER | CORE | TASK),instance_type,name,bid_price
                    instance_groups = []
                    groups.each do |group|
                      instance_count, instance_role, instance_size, name, bid_price = group.split(',')
            Severity: Minor
            Found in lib/awscli/emr.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 parse_custom_jar has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse_custom_jar(steps)
                    #parse jar_path(s3)*,name_of_step*,main_class,action_on_failure(TERMINATE_JOB_FLOW | CANCEL_AND_WAIT | CONTINUE),arg1=agr2=arg3,properties(k=v,k=v)
                    abort "invalid step pattern, expecting 'jar_path(s3)*,name_of_step*,main_class,action_on_failure,arg1=agr2=arg3,prop_k1=prop_v1,prop_k2=prop_v2)'" unless step =~ /(.*),(.*),(.*),(.*),(.*),(.*),(.*)/
                    jar, name, main_class, action_on_failure, extra_args, *job_conf = step.split(',')
                    if jar.empty? or name.empty?
            Severity: Minor
            Found in lib/awscli/emr.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

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

                    def create_ubuntu
                      create_ec2_object
                      ubuntu_amis    = {
                          'us-east-1'       => 'ami-9b85eef2',  #Virginia
                          'us-west-1'       => 'ami-9b2d03de',  #Northern California
            Severity: Major
            Found in lib/awscli/cli/ec2/instances.rb and 1 other location - About 1 hr to fix
            lib/awscli/cli/ec2/instances.rb on lines 204..224

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

            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

                    def create_centos
                      create_ec2_object
                      centos_amis    = {
                          'us-east-1'       => 'ami-a96b01c0',  #Virginia
                          'us-west-1'       => 'ami-51351b14',  #Northern California
            Severity: Major
            Found in lib/awscli/cli/ec2/instances.rb and 1 other location - About 1 hr to fix
            lib/awscli/cli/ec2/instances.rb on lines 233..254

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

            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 add_instance_group has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_instance_group(options)
                    opts = Marshal.load(Marshal.dump(options))
                    opts.reject! { |key| key == 'job_flow_id' }
                    opts.reject! { |key| key == 'region' }
                    abort 'invalid job id' unless @conn.describe_job_flows.body['JobFlows'].map { |job| job['JobFlowId'] }.include?(options[:job_flow_id])
            Severity: Minor
            Found in lib/awscli/emr.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 add_policy_document has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def add_policy_document(options)
                    document = options[:policy_document]
                    policyname = options[:policy_name]
                    #validate json document
                    doc_path = File.expand_path(document)
            Severity: Minor
            Found in lib/awscli/iam.rb - About 1 hr to fix

              Method list has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def list(options)
                      validate_job_ids options[:job_flow_ids] if options[:job_flow_ids]
                      opts = Marshal.load(Marshal.dump(options))
                      opts.reject! { |k| k == 'table' } if options[:table]
                      if job_flow_ids = opts.delete(:job_flow_ids)
              Severity: Minor
              Found in lib/awscli/emr.rb - About 1 hr to fix

                Method show_filters has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def show_filters
                        filters =
                          [
                            {:filter_name => "architecture", :desc => "Image Architecture"},
                            {:filter_name => "block-device-mapping.delete-on-termination", :desc => "Whether the Amazon EBS volume is deleted on instance termination"},
                Severity: Minor
                Found in lib/awscli/ec2.rb - About 1 hr to fix

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

                      def request_dynamo(region=nil)
                        # => returns AWS DynamoDB object
                        if region
                          Awscli::Errors.invalid_region unless Awscli::Instances::REGIONS.include?(region)
                          @config.reject!{ |key| key == 'region' } if @config['region']
                  Severity: Major
                  Found in lib/awscli/connection.rb and 2 other locations - About 1 hr to fix
                  lib/awscli/connection.rb on lines 63..72
                  lib/awscli/connection.rb on lines 75..84

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

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

                      def request_emr(region=nil)
                        # => returns AWS EMR object
                        if region
                          Awscli::Errors.invalid_region unless Awscli::Instances::REGIONS.include?(region)
                          @config.reject!{ |key| key == 'region' } if @config['region']
                  Severity: Major
                  Found in lib/awscli/connection.rb and 2 other locations - About 1 hr to fix
                  lib/awscli/connection.rb on lines 75..84
                  lib/awscli/connection.rb on lines 87..96

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

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

                      def request_cloudwatch(region=nil)
                        # => returns AWS CloudWatch object
                        if region
                          Awscli::Errors.invalid_region unless Awscli::Instances::REGIONS.include?(region)
                          @config.reject!{ |key| key == 'region' } if @config['region']
                  Severity: Major
                  Found in lib/awscli/connection.rb and 2 other locations - About 1 hr to fix
                  lib/awscli/connection.rb on lines 63..72
                  lib/awscli/connection.rb on lines 87..96

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language