mongodb/mongo-ruby-driver

View on GitHub
lib/mongo/uri/options_mapper.rb

Summary

Maintainability
D
1 day
Test Coverage

Class OptionsMapper has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

    class OptionsMapper

      include Loggable

      # Instantates the options mapper.
Severity: Minor
Found in lib/mongo/uri/options_mapper.rb - About 4 hrs to fix

    File options_mapper.rb has 337 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Mongo
      class URI
    
        # Performs mapping between URI options and Ruby options.
        #
    Severity: Minor
    Found in lib/mongo/uri/options_mapper.rb - About 4 hrs to fix

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

            def ruby_to_smc(opts)
              rv = {}
              URI_OPTION_MAP.each do |uri_key, spec|
                if spec[:group]
                  v = opts[spec[:group]]
      Severity: Minor
      Found in lib/mongo/uri/options_mapper.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 smc_to_ruby has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def smc_to_ruby(opts)
              uri_options = {}
      
              opts.each do |key, value|
                strategy = URI_OPTION_MAP[key.downcase]
      Severity: Minor
      Found in lib/mongo/uri/options_mapper.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 ruby_to_smc has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def ruby_to_smc(opts)
              rv = {}
              URI_OPTION_MAP.each do |uri_key, spec|
                if spec[:group]
                  v = opts[spec[:group]]
      Severity: Minor
      Found in lib/mongo/uri/options_mapper.rb - About 1 hr to fix

        Method add_uri_option has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_uri_option(key, value, uri_options)
                strategy = URI_OPTION_MAP[key.downcase]
                if strategy.nil?
                  log_warn("Unsupported URI option '#{key}' on URI '#{@string}'. It will be ignored.")
                  return
        Severity: Minor
        Found in lib/mongo/uri/options_mapper.rb - About 45 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 convert_max_staleness has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def convert_max_staleness(name, value)
                if /\A-?\d+\z/ =~ value
                  int = value.to_i
        
                  if int == -1
        Severity: Minor
        Found in lib/mongo/uri/options_mapper.rb - About 35 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

        There are no issues that match your filters.

        Category
        Status