cantino/huginn

View on GitHub

Showing 141 of 177 total issues

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

    Method json_serialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def json_serialize(*fields)
          fields.each do |field|
            class_eval <<-CODE
              serialize :#{field}, JsonWithIndifferentAccess
    
    
    Severity: Minor
    Found in app/concerns/json_serialized_field.rb - About 1 hr to fix

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

        Method extract_xml has 28 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: Minor
        Found in app/models/agents/website_agent.rb - About 1 hr to fix

          Method receive has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def receive(incoming_events)
                # if there are too many, dump a bunch to avoid getting rate limited
                if incoming_events.count > 20
                  incoming_events = incoming_events.first(20)
                end
          Severity: Minor
          Found in app/models/agents/twitter_publish_agent.rb - About 1 hr to fix

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

                def sortable_column(attribute, default_direction = nil, options = nil)
                  if options.nil? && (options = Hash.try_convert(default_direction))
                    default_direction = nil
                  end
                  default_direction ||= 'desc'
            Severity: Minor
            Found in app/controllers/concerns/sortable_table.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 diff_with! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def diff_with!(agent)
                  return unless agent.present?
            
                  self.agent = agent
            
            
            Severity: Minor
            Found in app/importers/scenario_import.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 validate_email_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def validate_email_options
                errors.add(
                  :base,
                  "subject and expected_receive_period_in_days are required"
                ) unless options['subject'].present? && options['expected_receive_period_in_days'].present?
            Severity: Minor
            Found in app/concerns/email_concern.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 receive has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def receive(incoming_events)
                  # if there are too many, dump a bunch to avoid getting rate limited
                  if incoming_events.count > 20
                    incoming_events = incoming_events.first(20)
                  end
            Severity: Minor
            Found in app/models/agents/weibo_publish_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 receive has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def receive(incoming_events)
                  memory['pending_calls'] ||= {}
                  interpolate_with_each(incoming_events) do |event|
                    message = (event.payload['message'].presence || event.payload['text'].presence || event.payload['sms'].presence).to_s
                    if message.present?
            Severity: Minor
            Found in app/models/agents/twilio_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 check has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def check
                  last_message = memory['last_message']
                  mqtt_client.connect
            
                  poll_thread = Thread.new do
            Severity: Minor
            Found in app/models/agents/mqtt_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 included has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.included(mod)
                  mod.module_exec do
                    include HasAuthors
                    include HasEnclosure
                    include HasLinks
            Severity: Minor
            Found in lib/feedjira_extension.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 working? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def working?
                  return false if recent_error_logs?
            
                  if interpolated['expected_update_period_in_days'].present?
                    return false unless event_created_within?(interpolated['expected_update_period_in_days'])
            Severity: Minor
            Found in app/models/agents/java_script_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 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

                    Severity
                    Category
                    Status
                    Source
                    Language