cantino/huginn

View on GitHub

Showing 177 of 177 total issues

File website_agent.rb has 610 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 55 (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 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 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

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

          return graph.vis
            .append("svg:line")
            .attr("x1", graph.x(minX))
            .attr("x2", graph.x(maxX))
            .attr("y1", graph.y(mean + 3 * standard_deviation))
      Severity: Major
      Found in app/assets/javascripts/graphing.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/graphing.js on lines 59..65

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

      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

          graph.vis
            .append("svg:line")
            .attr("x1", graph.x(minX))
            .attr("x2", graph.x(maxX))
            .attr("y1", graph.y(mean + 2 * standard_deviation))
      Severity: Major
      Found in app/assets/javascripts/graphing.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/graphing.js on lines 66..72

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

      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

      Method validate_extract_options! has 84 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

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

                    Severity
                    Category
                    Status
                    Source
                    Language