danryan/reveille

View on GitHub

Showing 14 of 14 total issues

Class StateMachine has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

  class StateMachine
    attr_reader :object, :initial_state, :previous_state, :current_state

    def initialize(object)
      @object = object
Severity: Minor
Found in lib/revily/state_machine.rb - About 2 hrs to fix

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

      def create
        self.resource = build_resource(resource_params) #, {unsafe: true})
    
        if resource.save
          if resource.active_for_authentication?
    Severity: Minor
    Found in app/controllers/v1/users/registrations_controller.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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def save
        return false unless valid?
    
        delegate_attributes_for_user
        delegate_attributes_for_account
    Severity: Minor
    Found in app/models/account/sign_up.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

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

      def resolve
        @incident = incidents.integration(params[:message], params[:key]).first
    
        respond_with @incident do |format|
          if @incident
    Severity: Minor
    Found in app/controllers/integration/provider_controller.rb and 1 other location - About 35 mins to fix
    app/controllers/integration/provider_controller.rb on lines 24..36

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

    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

      def acknowledge
        @incident = incidents.integration(params[:message], params[:key]).first
    
        respond_with @incident do |format|
          if @incident
    Severity: Minor
    Found in app/controllers/integration/provider_controller.rb and 1 other location - About 35 mins to fix
    app/controllers/integration/provider_controller.rb on lines 41..52

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

    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 trigger has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def trigger
        @incident = incidents.integration(params[:message], params[:key]).first_or_initialize(incident_params)
        @incident.account = current_account unless @incident.account_id?
        http_status = @incident.new_record? ? :created : :not_modified
    
    
    Severity: Minor
    Found in app/controllers/integration/provider_controller.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

    Method resolve has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def resolve
        @incident = incidents.integration(params[:message], params[:key]).first
    
        respond_with @incident do |format|
          if @incident
    Severity: Minor
    Found in app/controllers/integration/provider_controller.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

    Method acknowledge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def acknowledge
        @incident = incidents.integration(params[:message], params[:key]).first
    
        respond_with @incident do |format|
          if @incident
    Severity: Minor
    Found in app/controllers/integration/provider_controller.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

    Method association_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def association_attributes(association_name)
        association_name = association_name.to_sym
        association = object.send(association_name)
        association_type = association.class.name.downcase
        association_attributes = {}
    Severity: Minor
    Found in app/serializers/application_serializer.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

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

            def events(*events)
              @events ||= []
              return @events unless events.present?
              matched_events ||= Event::EventList.new(events).events
              @events.concat(matched_events).uniq! unless matched_events.blank?
    Severity: Minor
    Found in lib/revily/event/handler.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 generate_token_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def generate_token_for(object_or_class, attribute, options={})
            klass = object_or_class.is_a?(Class) ? object_or_class : object_or_class.class
    
            loop do
              token = generate_token(options)
    Severity: Minor
    Found in lib/revily/helpers/unique_token.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 handler_supports_events? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def handler_supports_events?
        return unless handler
        events.each do |event|
          unless handler && handler_class && handler_class.supports?(event)
            errors.add(:events, "handler does not support event #{event}")
    Severity: Minor
    Found in app/models/hook.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

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

          def message
            if incidents.length > 1
              "#{incidents.count} ALERTS"
            else
              "ALERT [#{incidents.first.service.name}] #{incidents.first.message}".truncate(128)
    Severity: Minor
    Found in lib/revily/event/notifier/sms.rb and 1 other location - About 15 mins to fix
    lib/revily/event/notifier/email.rb on lines 10..14

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

    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 2 locations. Consider refactoring.
    Open

          def message
            if incidents.length > 1
              "#{incidents.count} ALERTS"
            else
              "ALERT [#{incidents.first.service.name}] #{incidents.first.message}".truncate(128)
    Severity: Minor
    Found in lib/revily/event/notifier/email.rb and 1 other location - About 15 mins to fix
    lib/revily/event/notifier/sms.rb on lines 9..13

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

    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

    Severity
    Category
    Status
    Source
    Language