mongodb/mongo-ruby-driver

View on GitHub

Showing 447 of 447 total issues

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

        def update(user_or_name, options = {})
          user = generate(user_or_name, options)
          execute_operation(options) do |session|
            Operation::UpdateUser.new(
              user: user,
Severity: Minor
Found in lib/mongo/auth/user/view.rb and 1 other location - About 30 mins to fix
lib/mongo/auth/user/view.rb on lines 48..56

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

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

Avoid too many return statements within this method.
Open

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

    Avoid too many return statements within this method.
    Open

                return true
    Severity: Major
    Found in lib/mongo/cluster/sdam_flow.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

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

        Avoid too many return statements within this method.
        Open

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

          Avoid too many return statements within this method.
          Open

                    return nil
          Severity: Major
          Found in lib/mongo/auth/aws/credentials_retriever.rb - About 30 mins to fix

            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

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

                                module Int32
                          
                                  # Serializes a number to a 32-bit integer
                                  #
                                  # @param buffer [ String ] Buffer to receive the serialized Int32.
                          Severity: Minor
                          Found in lib/mongo/protocol/serializers.rb and 1 other location - About 30 mins to fix
                          lib/mongo/protocol/serializers.rb on lines 143..170

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

                          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

                                module Int64
                          
                                  # Serializes a number to a 64-bit integer
                                  #
                                  # @param buffer [ String ] Buffer to receive the serialized Int64.
                          Severity: Minor
                          Found in lib/mongo/protocol/serializers.rb and 1 other location - About 30 mins to fix
                          lib/mongo/protocol/serializers.rb on lines 109..136

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

                          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 @key_vault_client && @key_vault_client != options[:client] &&
                                    @key_vault_client.cluster != options[:client].cluster
                                  then
                                    begin
                                      @key_vault_client.close
                          Severity: Minor
                          Found in lib/mongo/crypt/auto_encrypter.rb and 1 other location - About 25 mins to fix
                          lib/mongo/crypt/auto_encrypter.rb on lines 163..172

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

                          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 @metadata_client && @metadata_client != options[:client] &&
                                    @metadata_client.cluster != options[:client].cluster
                                  then
                                    begin
                                      @metadata_client.close
                          Severity: Minor
                          Found in lib/mongo/crypt/auto_encrypter.rb and 1 other location - About 25 mins to fix
                          lib/mongo/crypt/auto_encrypter.rb on lines 152..161

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

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

                          Severity
                          Category
                          Status
                          Source
                          Language