virtualstaticvoid/taskinator

View on GitHub

Showing 16 of 16 total issues

File persistence.rb has 508 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'builder'

module Taskinator
  module Persistence

Severity: Major
Found in lib/taskinator/persistence.rb - About 1 day to fix

    Method constantize has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def constantize(camel_cased_word)
    
          # borrowed from activesupport/lib/active_support/inflector/methods.rb
    
          names = camel_cased_word.split('::')
    Severity: Minor
    Found in lib/taskinator/create_process_worker.rb - About 3 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

    Class Process has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Process
        include ::Comparable
    
        include Workflow
        include Persistence
    Severity: Minor
    Found in lib/taskinator/process.rb - About 2 hrs to fix

      Method define_process has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def define_process(*arg_list, &block)
            raise ProcessAlreadyDefinedError if respond_to?(:_create_process_)
      
            factory = arg_list.last.respond_to?(:call) ?
                        arg_list.pop :
      Severity: Minor
      Found in lib/taskinator/definition.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 visit_tasks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def visit_tasks(tasks)
              builder.tag!('tasks', :count => tasks.count) do |xml|
                tasks.each do |task|
                  xml.tag!('task', :key => task.key) do |xml2|
                    XmlSerializationVisitor.new(xml2, task, @base_visitor).visit
      Severity: Minor
      Found in lib/taskinator/persistence.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 deserialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def deserialize(yaml)
              values = YAML.load(yaml)
              if values.is_a?(Array)
                values = values.collect {|value|
                  (value.respond_to?(:model_id) && value.respond_to?(:find)) ? value.find : value
      Severity: Minor
      Found in lib/taskinator/persistence.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 define_process has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def define_process(*arg_list, &block)
            raise ProcessAlreadyDefinedError if respond_to?(:_create_process_)
      
            factory = arg_list.last.respond_to?(:call) ?
                        arg_list.pop :
      Severity: Minor
      Found in lib/taskinator/definition.rb - About 1 hr to fix

        Method serialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def serialize(values)
                # special case, convert models to global id's
                if values.is_a?(Array)
                  values = values.collect {|value|
                    value.respond_to?(:to_global_id) ? value.to_global_id : value
        Severity: Minor
        Found in lib/taskinator/persistence.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 payload_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def payload_for(state, additional={})
        
              # need to cache here, since this method hits redis, so can't be part of multi statement following
              process_key = self.process_key
        
        
        Severity: Minor
        Found in lib/taskinator/instrumentation.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 for_each has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def for_each(method, options={}, &block)
              raise ArgumentError, 'method' if method.nil?
              raise NoMethodError, method unless @executor.respond_to?(method)
              raise ArgumentError, 'block' unless block_given?
        
        
        Severity: Minor
        Found in lib/taskinator/builder.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 visit_tasks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def visit_tasks(tasks)
                tasks.each do |task|
                  RedisSerializationVisitor.new(@conn, task, @base_visitor).visit
                  @conn.rpush "#{@key}:tasks", task.uuid
                  unless task.is_a?(Task::SubProcess)
        Severity: Minor
        Found in lib/taskinator/persistence.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 complete! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def complete!
              transition(:completed) do
                instrument('taskinator.process.completed', completed_payload) do
                  complete if respond_to?(:complete)
                  # notify the parent task (if there is one) that this process has completed
        Severity: Minor
        Found in lib/taskinator/process.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 fail! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def fail!(error)
              transition(:failed) do
                instrument('taskinator.process.failed', failed_payload(error)) do
                  fail(error) if respond_to?(:fail)
                  # notify the parent task (if there is one) that this process has failed
        Severity: Minor
        Found in lib/taskinator/process.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 pause! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def pause!
              return unless enqueued? || processing?
        
              transition(:paused) do
                instrument('taskinator.process.paused', paused_payload) do
        Severity: Minor
        Found in lib/taskinator/process.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

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

              def inspect
                %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} uuid="#{uuid}", definition=:#{definition}, method=:#{method}, args=#{args}, current_state=:#{current_state}>)
        Severity: Minor
        Found in lib/taskinator/task.rb and 1 other location - About 25 mins to fix
        lib/taskinator/task.rb on lines 256..257

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

        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 inspect
                %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} uuid="#{uuid}", definition=:#{definition}, job=#{job}, args=#{args}, current_state=:#{current_state}>)
        Severity: Minor
        Found in lib/taskinator/task.rb and 1 other location - About 25 mins to fix
        lib/taskinator/task.rb on lines 202..203

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

        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