cantino/huginn

View on GitHub

Showing 141 of 177 total issues

File website_agent.rb has 655 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'nokogiri'
require 'date'

module Agents
  class WebsiteAgent < Agent
Severity: Major
Found in app/models/agents/website_agent.rb - About 1 day to fix

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

        def validate_extract_options!
          extraction_type = begin
            extraction_type()
          rescue StandardError
            extraction_type(options)
    Severity: Minor
    Found in app/models/agents/website_agent.rb - About 1 day 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 import has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

      def import(options = {})
        success = true
        guid = parsed_data['guid']
        description = parsed_data['description']
        name = parsed_data['name']
    Severity: Minor
    Found in app/importers/scenario_import.rb - About 4 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 extract_xml has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def extract_xml(doc)
          extract_each { |extraction_details, values|
            case
            when css = extraction_details['css']
              nodes = doc.css(css)
    Severity: Minor
    Found in app/models/agents/website_agent.rb - About 4 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 control! has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

      def control!
        control_targets.each do |target|
          interpolate_with('target' => target) do
            case action = control_action
            when 'run'
    Severity: Minor
    Found in app/concerns/agent_controller_concern.rb - About 4 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 validate_options has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_options
          # Check for required fields
          begin
            if !options['url'].include?('{{')
              url = interpolated['url']
    Severity: Minor
    Found in app/models/agents/ftpsite_agent.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

    Method validate_extract_options! has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def validate_extract_options!
          extraction_type = begin
            extraction_type()
          rescue StandardError
            extraction_type(options)
    Severity: Major
    Found in app/models/agents/website_agent.rb - About 3 hrs to fix

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

        def self.convert_hash(hash, options={})
          options = {:merge_path_attributes => false, :leading_dollarsign_is_jsonpath => false}.merge options
          keys_to_remove = []
          hash.tap do |hash|
            hash.each_pair do |key, value|
      Severity: Minor
      Found in lib/liquid_migrator.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

      Function handleDryRunButton has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static handleDryRunButton(button, data) {
            if (data == null) {
              data = button.form
                ? $(':input[name!="_method"]', button.form).serialize()
                : "";
      Severity: Major
      Found in app/assets/javascripts/components/utils.js - About 3 hrs to fix

        File agent-edit-page.js has 295 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        (function () {
          let formatAgentForSelect = undefined;
          const Cls = (this.AgentEditPage = class AgentEditPage {
            static initClass() {
              formatAgentForSelect = function (agent) {
        Severity: Minor
        Found in app/assets/javascripts/pages/agent-edit-page.js - About 3 hrs to fix

          Function initializeFormCompletable has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            return (window.initializeFormCompletable = function () {
              $("input[role~=validatable], select[role~=validatable]").on(
                "change",
                (e) => {
                  const form_data = getFormData(e.currentTarget);
          Severity: Major
          Found in app/assets/javascripts/components/form_configurable.js - About 3 hrs to fix

            Function check has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var check = function () {
                  const query = sinceId != null ? "?since_id=" + sinceId : "";
                  return $.getJSON("/worker_status" + query, function (json) {
                    for (var method of ["pending", "awaiting_retry", "recent_failures"]) {
                      var count = json[method];
            Severity: Major
            Found in app/assets/javascripts/components/worker-checker.js - About 3 hrs to fix

              Class AgentsController has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class AgentsController < ApplicationController
                include DotHelper
                include ActionView::Helpers::TextHelper
                include SortableTable
              
              
              Severity: Minor
              Found in app/controllers/agents_controller.rb - About 3 hrs to fix

                Method validate_options has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                    def validate_options
                      unless options['post_url'].present?
                        errors.add(:base, "post_url is a required field")
                      end
                
                
                Severity: Minor
                Found in app/models/agents/post_agent.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

                Function constructor has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    constructor() {
                      this.invokeDryRun = this.invokeDryRun.bind(this);
                      $("#agent_source_ids").on("change", this.showEventDescriptions);
                      this.showCorrectRegionsOnStartup();
                      $("form.agent-form").on("submit", () => this.updateFromEditors());
                Severity: Major
                Found in app/assets/javascripts/pages/agent-edit-page.js - About 2 hrs to fix

                  Class WebsiteAgent has 25 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class WebsiteAgent < Agent
                      include WebRequestConcern
                  
                      can_dry_run!
                      can_order_created_events!
                  Severity: Minor
                  Found in app/models/agents/website_agent.rb - About 2 hrs to fix

                    Method receive_web_request has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def receive_web_request(request)
                          # check the secret
                          secret = request.path_parameters[:secret]
                          return ["Not Authorized", 401] unless secret == interpolated['secret']
                    
                    
                    Severity: Minor
                    Found in app/models/agents/webhook_agent.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 receive has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def receive(incoming_events)
                          incoming_events.each do |event|
                            interpolate_with(event) do
                              post_params = {}
                    
                    
                    Severity: Minor
                    Found in app/models/agents/pushover_agent.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 send_telegram_messages has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def send_telegram_messages(field, params)
                          if interpolated['long_message'] == 'split'
                            if field == :text
                              params[:text].scan(/\G\s*(?:\w{4096}|.{1,4096}(?=\b|\z))/m) do |message|
                                message.strip!
                    Severity: Minor
                    Found in app/models/agents/telegram_agent.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

                    Function success has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            success: (modal_data) => {
                              return Utils.showDynamicModal(modal_data, {
                                body: (body) => {
                                  let previous;
                                  const form = $(body).find(".dry-run-form");
                    Severity: Major
                    Found in app/assets/javascripts/components/utils.js - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language