wbotelhos/normalizy

View on GitHub

Showing 7 of 9 total issues

Method matches? has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def matches?(subject)
        @subject = subject

        if @with.present?
          options = @subject.class.normalizy_rules[@attribute]
Severity: Minor
Found in lib/normalizy/rspec/matcher.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 extract_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_value(value, filter, options, block)
        if filter.respond_to?(:call)
          if filter.method(:call).arity == -2
            filter.call value, options, &block
          else
Severity: Minor
Found in lib/normalizy/extensions.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 call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def call(input, options = {})
          if input.is_a?(String)
            return input if input.blank?

            Time.use_zone(time_zone(options)) do
Severity: Minor
Found in lib/normalizy/filters/date.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 normalizy has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def normalizy(*args, &block)
        options = args.extract_options!
        rules   = options[:with]

        self.normalizy_rules ||= {}
Severity: Minor
Found in lib/normalizy/extensions.rb - About 1 hr to fix

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

            def call(input, options = {})
              return input unless input.is_a?(String)
    
              value = input.gsub(/[^[0-9-]#{separator(options)}]/, '')
    
    
    Severity: Minor
    Found in lib/normalizy/filters/money.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def call(input, options = {})
              return input unless input.is_a?(String)
    
              value = input.gsub(/[^[0-9]#{separator(options)}]/, '')
    
    
    Severity: Minor
    Found in lib/normalizy/filters/percent.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 normalizy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def normalizy(*args, &block)
            options = args.extract_options!
            rules   = options[:with]
    
            self.normalizy_rules ||= {}
    Severity: Minor
    Found in lib/normalizy/extensions.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

    Severity
    Category
    Status
    Source
    Language