jibeinc/web_minion

View on GitHub

Showing 9 of 9 total issues

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

  class MechanizeBot < WebMinion::Bot
    def initialize(config = {})
      super(config)
      @bot = Mechanize.new
    end
Severity: Minor
Found in lib/web_minion/bots/mechanize_bot.rb - About 2 hrs to fix

    Method replace_variable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def replace_variable(var)
          if var.is_a?(Hash)
            return handle_hash_replacement(var)
          else
            return var unless var.is_a?(String)
    Severity: Minor
    Found in lib/web_minion/step.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 perform has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def perform(bot, saved_values)
          element = nil
          status = @steps.map do |step|
            if step.validator?
              step.perform(bot, element, saved_values)
    Severity: Minor
    Found in lib/web_minion/action.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 build_from_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.build_from_hash(fields = {}, vars = {})
          steps = fields["steps"].map do |step|
            begin
              Step.new(step.merge("vars" => vars))
            rescue NoValueForVariableError => e
    Severity: Minor
    Found in lib/web_minion/action.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 parse_status has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_status(status)
          if [TrueClass, FalseClass].include? status.class
            status ? "Successful" : "Unsuccessful"
          elsif [String, Symbol].include? status.class
            unless VALID_STATUSES.include? status.capitalize
    Severity: Minor
    Found in lib/web_minion/histories/history.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 set_file_upload has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_file_upload(target, value, element)
          if target.is_a?(String) && %w(first last).include?(target)
            file_upload = element.find_all(:css, "input[type='file']").send(target)
          elsif target.is_a?(String)
            target_type = %r{^//} =~ target ? :xpath : :css
    Severity: Minor
    Found in lib/web_minion/bots/capybara_bot.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 execute_action has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def execute_action(action, saved_values = {})
          @curr_action = action
          @history.action_history << ActionHistory.new(action.name, action.key)
          status = action.perform(@bot, saved_values)
          update_action_history(status)
    Severity: Minor
    Found in lib/web_minion/flow.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 execute_step has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def execute_step(method, target, value = nil, element = nil, values_hash = {})
    Severity: Minor
    Found in lib/web_minion/bots/bot.rb - About 35 mins to fix

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

          def select_radio_button(target, value, element)
            if target.is_a?(Array)
              return target.map { |tar| select_radio_button(tar, value, element) }
            elsif target.is_a?(Hash)
              key, value = target.first
      Severity: Minor
      Found in lib/web_minion/bots/capybara_bot.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

      Severity
      Category
      Status
      Source
      Language