mxenabled/action_subscriber

View on GitHub

Showing 9 of 9 total issues

Method start_subscriber_for_subscription has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def start_subscriber_for_subscription(subscription)
        route = subscription[:route]
        queue = subscription[:queue]
        channel = queue.channel
        threadpool = ::ActionSubscriber::ThreadPools.threadpools.fetch(route.threadpool_name)
Severity: Minor
Found in lib/action_subscriber/bunny/subscriber.rb - About 1 hr to fix

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

              ::ActiveSupport::Notifications.instrument "received_event.action_subscriber", :payload_size => encoded_payload.bytesize, :queue => queue.name
              properties = {
                :action => route.action,
                :channel => queue.channel,
                :content_type => metadata.content_type,
    Severity: Major
    Found in lib/action_subscriber/march_hare/subscriber.rb and 1 other location - About 1 hr to fix
    lib/action_subscriber/bunny/subscriber.rb on lines 55..69

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

    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

              ::ActiveSupport::Notifications.instrument "received_event.action_subscriber", :payload_size => encoded_payload.bytesize, :queue => queue.name
              properties = {
                :action => route.action,
                :channel => queue.channel,
                :content_type => properties.content_type,
    Severity: Major
    Found in lib/action_subscriber/bunny/subscriber.rb and 1 other location - About 1 hr to fix
    lib/action_subscriber/march_hare/subscriber.rb on lines 55..69

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

    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 start_subscriber_for_subscription has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def start_subscriber_for_subscription(subscription)
            route = subscription[:route]
            queue = subscription[:queue]
            queue.channel.prefetch = route.prefetch if route.acknowledgements?
            threadpool = ::ActionSubscriber::ThreadPools.threadpools.fetch(route.threadpool_name)
    Severity: Minor
    Found in lib/action_subscriber/march_hare/subscriber.rb - About 1 hr to fix

      Method _run_action_at_least_once_with_filters has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def _run_action_at_least_once_with_filters(env, action)
            processed_acknowledgement = false
            rejected_message = false
      
            _run_action_with_filters(env, action)
      Severity: Minor
      Found in lib/action_subscriber/dsl.rb - About 1 hr to fix

        Method parse_amqp_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.parse_amqp_url(connection_string)
              uri = ::URI.parse(connection_string)
              raise ArgumentError.new("Connection URI must use amqp or amqps schema (example: amqp://bus.megacorp.internal:5766), learn more at http://bit.ly/ks8MXK") unless %w{amqp amqps}.include?(uri.scheme)
        
              opts = {}
        Severity: Minor
        Found in lib/action_subscriber/uri.rb - About 55 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 local_application_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def local_application_name(reload = false)
              if reload || @_local_application_name.nil?
                @_local_application_name = case
                                      when ENV['APP_NAME'] then
                                        ENV['APP_NAME'].to_s.dup
        Severity: Minor
        Found in lib/action_subscriber/subscribable.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

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

                @_local_application_name = case
                                      when ENV['APP_NAME'] then
                                        ENV['APP_NAME'].to_s.dup
                                      when defined?(::Rails) then
                                        if ::Rails.application.class.respond_to?(:module_parent_name)
        Severity: Minor
        Found in lib/action_subscriber/subscribable.rb and 1 other location - About 30 mins to fix
        lib/action_subscriber/router.rb on lines 57..67

        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

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

                local_application_name = case
                                         when ENV['APP_NAME'] then
                                           ENV['APP_NAME'].to_s.dup
                                         when defined?(::Rails) then
                                           if ::Rails.application.class.respond_to?(:module_parent_name)
        Severity: Minor
        Found in lib/action_subscriber/router.rb and 1 other location - About 30 mins to fix
        lib/action_subscriber/subscribable.rb on lines 34..44

        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

        Severity
        Category
        Status
        Source
        Language