cantino/huginn

View on GitHub

Showing 177 of 177 total issues

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

    def check
      hydra = Typhoeus::Hydra.new
      request = Typhoeus::Request.new(check_url, followlocation: true)
      request.on_success do |response|
        page = Nokogiri::XML response.body
Severity: Minor
Found in app/models/agents/public_transport_agent.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 execute_js has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def execute_js(js_function, incoming_events = [])
      js_function = js_function == "check" ? "check" : "receive"
      context = MiniRacer::Context.new
      context.eval(setup_javascript)

Severity: Minor
Found in app/models/agents/java_script_agent.rb - About 1 hr to fix

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

      def handle_request
        user = User.find_by_id(params[:user_id])
        if user
          agent = user.agents.find_by_id(params[:agent_id])
          if agent
    Severity: Minor
    Found in app/controllers/web_requests_controller.rb - About 1 hr to fix

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

          def open_ftp(uri)
            ftp = Net::FTP.new
      
            log "Connecting to #{uri.host}#{':%d' % uri.port if uri.port != uri.default_port}"
            ftp.connect(uri.host, uri.port)
      Severity: Minor
      Found in app/models/agents/ftpsite_agent.rb - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

              unless options['account_sid'].present? && options['auth_token'].present? && options['sender_cell'].present? && options['receiver_cell'].present? && options['expected_receive_period_in_days'].present? && options['receive_call'].present? && options['receive_text'].present?
                errors.add(:base,
                           'account_sid, auth_token, sender_cell, receiver_cell, receive_text, receive_call and expected_receive_period_in_days are all required')
              end
        Severity: Major
        Found in app/models/agents/twilio_agent.rb - About 1 hr to fix

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

              def handle_data(body, url, existing_payload)
                # Beware, url may be a URI object, string or nil
          
                doc = parse(body)
          
          
          Severity: Minor
          Found in app/models/agents/website_agent.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 validate_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_options
                if (spec = options['schedule']).present?
                  begin
                    cron = Fugit::Cron.new(spec) or raise ArgumentError
                    unless second_precision_enabled || (cron.seconds - [0, 15, 30, 45, 60]).empty?
          Severity: Minor
          Found in app/models/agents/scheduler_agent.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 grab_config_with_cmd! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def grab_config_with_cmd!(cmd, opts = {})
              config_data = capture(cmd, opts)
              $config = {}
              if config_data !~ /has no config vars/
                config_data.split("\n").map do |line|
          Severity: Minor
          Found in lib/setup_tools.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 receive_web_request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def receive_web_request(request)
                params = request.params.except(:action, :controller, :agent_id, :user_id, :format)
                method = request.method_symbol.to_s
                headers = request.headers
          
          
          Severity: Minor
          Found in app/models/agents/twilio_receive_text_agent.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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def create
                attrs = agent_params
                if agent = current_user.agents.find_by(id: params[:agent_id])
                  # POST /agents/:id/dry_run
                  if attrs.present?
          Severity: Minor
          Found in app/controllers/agents/dry_runs_controller.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 configure_params has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def configure_params(params)
                params[:chat_id] = interpolated['chat_id']
                params[:disable_notification] =
                  interpolated['disable_notification'] if interpolated['disable_notification'].present?
                if params.has_key?(:text)
          Severity: Minor
          Found in app/models/agents/telegram_agent.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_table_sort has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def set_table_sort(sort_options)
              valid_sorts = sort_options[:sorts] or raise ArgumentError.new("You must specify :sorts as an array of valid sort attributes.")
              default = sort_options[:default] || { valid_sorts.first.to_sym => :desc }
          
              if params[:sort].present?
          Severity: Minor
          Found in app/controllers/concerns/sortable_table.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 convert_string has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.convert_string(string, leading_dollarsign_is_jsonpath=false)
              if string == true || string == false
                # there might be empty *_path attributes for boolean defaults
                string
              elsif string[0] == '$' && leading_dollarsign_is_jsonpath
          Severity: Minor
          Found in lib/liquid_migrator.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 send_message has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def send_message(options)
              @groups = options[:groups]
              @headline = options[:headline]
              @body = options[:body]
          
          
          Severity: Minor
          Found in app/mailers/system_mailer.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 apply_compiled_matchers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def apply_compiled_matchers(matchers, event, &block)
                return yield if matchers.nil?
          
                # event.payload.dup does not work; HashWithIndifferentAccess is
                # a source of trouble here.
          Severity: Minor
          Found in app/models/agents/event_formatting_agent.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

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

              hideEventCreation() {
                $(".event-related-region .select2-container").hide();
                $(".event-related-region .cannot-create-events").show();
                return $(".event-related-region").data("can-create-events", false);
              }
          Severity: Minor
          Found in app/assets/javascripts/pages/agent-edit-page.js and 1 other location - About 50 mins to fix
          app/assets/javascripts/pages/agent-edit-page.js on lines 207..211

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

          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

              showEventCreation() {
                $(".event-related-region .select2-container").show();
                $(".event-related-region .cannot-create-events").hide();
                return $(".event-related-region").data("can-create-events", true);
              }
          Severity: Minor
          Found in app/assets/javascripts/pages/agent-edit-page.js and 1 other location - About 50 mins to fix
          app/assets/javascripts/pages/agent-edit-page.js on lines 201..205

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

          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

          Avoid deeply nested control flow statements.
          Open

                          if re && !re.names.include?(index)
                            errors.add(:base, "no named capture #{index.inspect} found in regexp for #{name.inspect})")
                          end
          Severity: Major
          Found in app/models/agents/website_agent.rb - About 45 mins to fix

            Method load_workers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def load_workers
                workers = {}
                @@agents.each do |klass|
                  next if @options[:only] && !@options[:only].include?(klass)
                  next if @options[:except] && @options[:except].include?(klass)
            Severity: Minor
            Found in lib/agent_runner.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

            Avoid deeply nested control flow statements.
            Open

                            case details['xpath']
                            when String
                              # ok
                            when nil
                              errors.add(:base,
            Severity: Major
            Found in app/models/agents/website_agent.rb - About 45 mins to fix
              Severity
              Category
              Status
              Source
              Language