alsemyonov/synapses

View on GitHub

Showing 5 of 5 total issues

Method setup! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def setup!
      EM.schedule do
        setup_channel = AMQP.channel
        cache = {
          exchanges: {},
Severity: Minor
Found in lib/synapses/contract.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 message_handler has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def message_handler(metadata, payload)
      if (typed_subscriptions = self.subscriptions[metadata.type]).any?
        typed_subscriptions.each do |message_class, block|
          message = message_class.new(payload, metadata)
          instance_exec(message, &block)
Severity: Minor
Found in lib/synapses/consumer.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 setup! has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setup!
      EM.schedule do
        setup_channel = AMQP.channel
        cache = {
          exchanges: {},
Severity: Minor
Found in lib/synapses/contract.rb - About 1 hr to fix

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

        def publish(message, metadata = {}, &block)
          metadata = message.metadata.merge(metadata) if message.respond_to?(:metadata)
          logger.debug(to_s) { "scheduling publishing of #{message} with metadata: #{metadata.inspect}" }
          EM.schedule do
            exchange.publish(message, metadata) do
    Severity: Minor
    Found in lib/synapses/producer.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 write! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def write!
            FileUtils.mkdir_p(contracts_autogen_dir)
            contract.namespaces.each do |namespace, contents|
              next if namespace == 'amq'
              file_name = "#{namespace}.rb"
    Severity: Minor
    Found in lib/synapses/contract/generator.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