cantino/huginn

View on GitHub

Showing 141 of 177 total issues

Method extract_xml has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def extract_xml(doc)
      extract_each { |extraction_details, values|
        case
        when css = extraction_details['css']
          nodes = doc.css(css)
Severity: Major
Found in app/models/agents/website_agent.rb - About 2 hrs to fix

    Function renderGraph has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    window.renderGraph = function ($chart, data, peaks, name) {
      const graph = new Rickshaw.Graph({
        element: $chart.find(".chart").get(0),
        width: 700,
        height: 240,
    Severity: Major
    Found in app/assets/javascripts/graphing.js - About 2 hrs to fix

      Method model has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def model(which_day)
            value = pirate_weather[which_day - 1]
            if value
              timestamp = Time.at(value.time)
              {
      Severity: Major
      Found in app/models/agents/weather_agent.rb - About 2 hrs to fix

        File feedjira_extension.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'feedjira'
        require 'digest'
        require 'mail'
        
        module FeedjiraExtension
        Severity: Minor
        Found in lib/feedjira_extension.rb - About 2 hrs to fix

          Method validate_matchers has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_matchers
                matchers = options['matchers'] or return
          
                unless matchers.is_a?(Array)
                  errors.add(:base, "matchers must be an array if present")
          Severity: Minor
          Found in app/models/agents/event_formatting_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 body has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      body: (body) => {
                        let previous;
                        const form = $(body).find(".dry-run-form");
                        const payload_editor = form.find(".payload-editor");
          
          
          Severity: Major
          Found in app/assets/javascripts/components/utils.js - About 2 hrs to fix

            Method receive_web_request has 59 lines of code (exceeds 25 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: Major
            Found in app/models/agents/webhook_agent.rb - About 2 hrs to fix

              Method get_issues has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_issues(since)
                    startAt = 0
                    issues = []
              
                    # JQL doesn't have an ability to specify timezones
              Severity: Minor
              Found in app/models/agents/jira_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 validate_options has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_options
                    # Check for required fields
                    errors.add(:base,
                               "either url, url_from_event, or data_from_event are required") unless options['url'].present? || options['url_from_event'].present? || options['data_from_event'].present?
                    errors.add(:base,
              Severity: Minor
              Found in app/models/agents/website_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 handleTypeChange has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  handleTypeChange(firstTime) {
                    $(".event-descriptions").html("").hide();
                    const type = $("#agent_type").val();
              
                    if (type === "Agent") {
              Severity: Major
              Found in app/assets/javascripts/pages/agent-edit-page.js - About 2 hrs to fix

                Method validate_location has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def validate_location
                      errors.add(:base, "location is required") unless location.present?
                      if location =~ VALID_COORDS_REGEX
                        lat, lon = coordinates
                        errors.add :base, "too low of a latitude" unless lat > -90
                Severity: Minor
                Found in app/models/agents/weather_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 handle_request has a Cognitive Complexity of 16 (exceeds 5 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 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 serialize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def serialize(incoming_events)
                      mo = interpolated(incoming_events.first)
                      rows = rows_from_events(incoming_events, mo)
                      csv = CSV.generate(col_sep: separator(mo), force_quotes: true) do |csv|
                        if boolify(mo['with_header']) && rows.first.is_a?(Hash)
                Severity: Minor
                Found in app/models/agents/csv_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 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def receive(incoming_events)
                      max_keys = max_keys()
                
                      incoming_events.each do |event|
                        interpolate_with(event) do
                Severity: Minor
                Found in app/models/agents/key_value_store_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 50 lines of code (exceeds 25 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

                  Method import has 48 lines of code (exceeds 25 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 1 hr to fix

                    Method validate_options has 47 lines of code (exceeds 25 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 1 hr to fix

                      Method control! has 44 lines of code (exceeds 25 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 1 hr to fix

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

                            def receive(incoming_events)
                              interpolate_with_each(incoming_events) do |event|
                                existing_payload = interpolated['mode'].to_s == "merge" ? event.payload : {}
                        
                                if data_from_event = options['data_from_event'].presence
                        Severity: Minor
                        Found in app/models/agents/website_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 schedule_scheduler_agent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def schedule_scheduler_agent(agent)
                            job = scheduler_agent_job(agent)
                        
                            if agent.unavailable?
                              if job
                        Severity: Minor
                        Found in lib/huginn_scheduler.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

                        Severity
                        Category
                        Status
                        Source
                        Language