ashrithr/awscli

View on GitHub

Showing 134 of 134 total issues

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

      def create(options)
        username = options[:user_name]
        @conn.create_user(username, options[:path] ||= '/')
        puts "Created User: #{username}"
        if options[:password]
Severity: Minor
Found in lib/awscli/iam.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

File s3.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Awscli
  module S3
    require 'thread'
    require 'digest/md5'
    require 'base64'
Severity: Minor
Found in lib/awscli/s3.rb - About 2 hrs to fix

    File instances.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module AwsCli
      module CLI
        module EC2
          require 'awscli/cli/ec2'
          require 'awscli/helper'
    Severity: Minor
    Found in lib/awscli/cli/ec2/instances.rb - About 2 hrs to fix

      Method terminate_instances has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def terminate_instances(delete_attached_volumes = false)
              block_mappings = []
              if agree('Are you sure want to delete all the servers that are running ?  ')
                @conn.servers.all.each do |server|
                  server.destroy if server.state == 'running' || server.state == 'stopped'
      Severity: Minor
      Found in lib/awscli/ec2.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 create has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def create(options)
              # => validate & parse options
              opts = Marshal.load(Marshal.dump(options))
              #launch conf name
              abort "Launch configuration name not found: #{options[:launch_configuration_name]}" unless @conn.configurations.get(options[:launch_configuration_name])
      Severity: Major
      Found in lib/awscli/as.rb - About 2 hrs to fix

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

                if options[:expected_attr] #-a
                  expected_attr_name, expected_attr_type, expected_attr_value = options[:expected_attr].split(':')
                  if expected_attr_name and expected_attr_type and expected_attr_value
                    if options[:expected_exists] and options[:expected_exists] == 'true' #-a Id:S:001 -e true
                      opts['Expected'] = { expected_attr_name => { 'Value' => { expected_attr_type => expected_attr_value }, 'Exists' => options[:expected_exists] } }
        Severity: Major
        Found in lib/awscli/dynamo.rb and 2 other locations - About 2 hrs to fix
        lib/awscli/dynamo.rb on lines 189..205
        lib/awscli/dynamo.rb on lines 393..409

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

        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

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

                if options[:expected_attr] #-a
                  expected_attr_name, expected_attr_type, expected_attr_value = options[:expected_attr].split(':')
                  if expected_attr_name and expected_attr_type and expected_attr_value
                    if options[:expected_exists] and options[:expected_exists] == 'true' #-a Id:S:001 -e true
                      opts['Expected'] = { expected_attr_name => { 'Value' => { expected_attr_type => expected_attr_value }, 'Exists' => options[:expected_exists] } }
        Severity: Major
        Found in lib/awscli/dynamo.rb and 2 other locations - About 2 hrs to fix
        lib/awscli/dynamo.rb on lines 352..368
        lib/awscli/dynamo.rb on lines 393..409

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

        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

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

                if options[:expected_attr] #-e
                  expected_attr_name, expected_attr_type, expected_attr_value = options[:expected_attr].split(':')
                  if expected_attr_name and expected_attr_type and expected_attr_value
                    if options[:expected_exists] and options[:expected_exists] == 'true' #-e Id:S:001 -x true
                      opts['Expected'] = { expected_attr_name => { 'Value' => { expected_attr_type => expected_attr_value }, 'Exists' => options[:expected_exists] } }
        Severity: Major
        Found in lib/awscli/dynamo.rb and 2 other locations - About 2 hrs to fix
        lib/awscli/dynamo.rb on lines 189..205
        lib/awscli/dynamo.rb on lines 352..368

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

        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 multipart_upload has 57 lines of code (exceeds 25 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: Major
        Found in lib/awscli/s3.rb - About 2 hrs to fix

          Method batch_write has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                def batch_write(options)
                  request_items = {}
                  #request_items['RequestItems'] = {}
                  options[:put_requests] and options[:put_requests].each do |request|
                    #table_name,col_name1:col_type1:col_value1,col_name2:col_type2:col_value2 ..
          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 get has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                def get(options)
                  #get_item(table_name, key, options = {})
                  opts = {}
                  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 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 create has 53 lines of code (exceeds 25 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: Major
          Found in lib/awscli/as.rb - About 2 hrs to fix

            Method create has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def create(options)
                    username = options[:user_name]
                    @conn.create_user(username, options[:path] ||= '/')
                    puts "Created User: #{username}"
                    if options[:password]
            Severity: Major
            Found in lib/awscli/iam.rb - About 2 hrs to fix

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

                    def create(options)
                      # => validate & parse options
                      opts = Marshal.load(Marshal.dump(options))
                      #launch conf name
                      abort "Launch configuration name not found: #{options[:launch_configuration_name]}" unless @conn.configurations.get(options[:launch_configuration_name])
              Severity: Minor
              Found in lib/awscli/as.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

              File as.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module Awscli
                module As
              
                  class Activities
                    def initialize(connection)
              Severity: Minor
              Found in lib/awscli/as.rb - About 2 hrs to fix

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

                  Method upload_file_rec has 47 lines of code (exceeds 25 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

                    Method update has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def update(options)
                            opts = {}
                            key = {}
                            attribute_updates = {}
                            #Build and validate key
                    Severity: Minor
                    Found in lib/awscli/dynamo.rb - About 1 hr to fix

                      Method batch_write has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def batch_write(options)
                              request_items = {}
                              #request_items['RequestItems'] = {}
                              options[:put_requests] and options[:put_requests].each do |request|
                                #table_name,col_name1:col_type1:col_value1,col_name2:col_type2:col_value2 ..
                      Severity: Minor
                      Found in lib/awscli/dynamo.rb - About 1 hr to fix

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

                                def scan
                                  unless options[:table_name]
                                    abort 'option --table-name is required.'
                                  end
                                  if options[:scan_filter]
                        Severity: Minor
                        Found in lib/awscli/cli/dynamo/item.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

                        Severity
                        Category
                        Status
                        Source
                        Language