mongodb/mongo-ruby-driver

View on GitHub

Showing 393 of 447 total issues

Avoid too many return statements within this method.
Open

        return :secondary if secondary?
Severity: Major
Found in lib/mongo/server/description.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return false
    Severity: Major
    Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                return false
      Severity: Major
      Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return false
        Severity: Major
        Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return false
          Severity: Major
          Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return false
            Severity: Major
            Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return false
              Severity: Major
              Found in lib/mongo/socket/ocsp_verifier.rb - About 30 mins to fix

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

                      def default_mechanism
                        if description.nil?
                          raise Mongo::Error, 'Trying to query default mechanism when handshake has not completed'
                        end
                
                
                Severity: Minor
                Found in lib/mongo/server/pending_connection.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

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

                    def create(opts = {})
                      # Passing read options to create command causes it to break.
                      # Filter the read options out. Session is also excluded here as it gets
                      # used by the call to with_session and should not be part of the
                      # operation. If it gets passed to the operation it would fail BSON
                Severity: Minor
                Found in lib/mongo/collection.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

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

                      def initialize(server, event_listeners, monitoring, options = {})
                        unless monitoring.is_a?(Monitoring)
                          raise ArgumentError, "Wrong monitoring type: #{monitoring.inspect}"
                        end
                        unless options[:app_metadata]
                Severity: Minor
                Found in lib/mongo/server/monitor.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

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

                      def initialize(options = {})
                        @app_name = options[:app_name].to_s if options[:app_name]
                        @platform = options[:platform]
                
                        @purpose = check_purpose!(options[:purpose])
                Severity: Minor
                Found in lib/mongo/server/app_metadata.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

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

                    def with(new_options)
                      new_options.keys.each do |k|
                        raise Error::UnchangeableCollectionOption.new(k) unless CHANGEABLE_OPTIONS.include?(k)
                      end
                      options = @options.dup
                Severity: Minor
                Found in lib/mongo/collection.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

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

                    def validate_camel_case_read_preference_mode(mode)
                      return unless enabled?
                      if mode
                        unless %w(primary primaryPreferred secondary secondaryPreferred nearest).include?(mode.to_s)
                          raise Error::LintError, "Invalid read preference mode: #{mode}"
                Severity: Minor
                Found in lib/mongo/lint.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

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

                        def prepare_web_identity_inputs
                          token_file = ENV['AWS_WEB_IDENTITY_TOKEN_FILE']
                          role_arn = ENV['AWS_ROLE_ARN']
                          if token_file.nil? || role_arn.nil?
                            return nil
                Severity: Minor
                Found in lib/mongo/auth/aws/credentials_retriever.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

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

                  def self.hangul_comp_one(string)
                    length = string.length
                    if length>1 and 0 <= (lead =string[0].ord-LBASE) and lead  < LCOUNT and
                                    0 <= (vowel=string[1].ord-VBASE) and vowel < VCOUNT
                      lead_vowel = SBASE + (lead * VCOUNT + vowel) * TCOUNT
                Severity: Minor
                Found in lib/mongo/auth/stringprep/unicode_normalize/normalize.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

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

                    def validate_camel_case_read_preference(read_pref)
                      return unless enabled?
                      return if read_pref.nil?
                      unless read_pref.is_a?(Hash)
                        raise Error::LintError, "Read preference is not a hash: #{read_pref}"
                Severity: Minor
                Found in lib/mongo/lint.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

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

                      def canonicalize_ruby_options(options)
                        Options::Redacted.new(Hash[options.map do |k, v|
                          if k == :auth_mech_properties || k == 'auth_mech_properties'
                            if v
                              v = Hash[v.map { |pk, pv| [pk.downcase, pv] }]
                Severity: Minor
                Found in lib/mongo/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

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

                    def update_server_descriptions
                      servers_list.each do |server|
                        if server.address == updated_desc.address
                          # SDAM flow must be run when topology version in the new description
                          # is equal to the current topology version, per the example in
                Severity: Minor
                Found in lib/mongo/cluster/sdam_flow.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

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

                        def credentials
                          credentials = credentials_from_user(user)
                          return credentials unless credentials.nil?
                
                          credentials = credentials_from_environment
                Severity: Minor
                Found in lib/mongo/auth/aws/credentials_retriever.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

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

                    def validate_underscore_read_preference(read_pref)
                      return unless enabled?
                      return if read_pref.nil?
                      unless read_pref.is_a?(Hash)
                        raise Error::LintError, "Read preference is not a hash: #{read_pref}"
                Severity: Minor
                Found in lib/mongo/lint.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

                Severity
                Category
                Status
                Source
                Language