cantino/huginn

View on GitHub

Showing 141 of 177 total issues

Method handle has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def handle(data, event = Event.new, headers)
      url = interpolated(event.payload)[:post_url]

      case method
      when 'get', 'delete'
Severity: Minor
Found in app/models/agents/post_agent.rb - About 1 hr to fix

    Method included has 40 lines of code (exceeds 25 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

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

          def check
            memory[:ids] ||= []
            memory[:last_liked] ||= 0
      
            # Request Likes of blog_name after the last stored timestamp (or default of 0)
      Severity: Minor
      Found in app/models/agents/tumblr_likes_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 handle has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(data, event = Event.new, headers)
            url = interpolated(event.payload)[:post_url]
      
            case method
            when 'get', 'delete'
      Severity: Minor
      Found in app/models/agents/post_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 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.included(mod)
            mod.module_exec do
              sax_config.top_level_elements['link'].clear
              sax_config.collection_elements['link'].clear
      
      
      Severity: Minor
      Found in lib/feedjira_extension.rb - About 1 hr to fix

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

          Method nav_link has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def nav_link(name, path, options = {}, &block)
              content = link_to(name, path, options)
              active = current_page?(path)
              if block
                # Passing a block signifies that the link is a header of a hover
          Severity: Minor
          Found in app/helpers/application_helper.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_options has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_options
                errors.add(:base, 'auth_token is required') unless options['auth_token'].present?
                errors.add(:base, 'chat_id is required') unless options['chat_id'].present?
                errors.add(:base,
                           'caption should be 1024 characters or less') if interpolated['caption'].present? && interpolated['caption'].length > 1024 && (!interpolated['long_message'].present? || interpolated['long_message'] != 'split')
          Severity: Minor
          Found in app/models/agents/telegram_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 validate_options has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_options
                if options['mode'].blank? || !['read', 'write'].include?(options['mode'])
                  errors.add(:base, "The 'mode' option is required and must be set to 'read' or 'write'")
                end
                if options['bucket'].blank?
          Severity: Minor
          Found in app/models/agents/s3_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 generate_diff has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def generate_diff
              @agent_diffs = (parsed_data['agents'] || []).map.with_index do |agent_data, index|
                # AgentDiff is defined at the end of this file.
                agent_diff = AgentDiff.new(agent_data, parsed_data['schema_version'])
                if existing_scenario
          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

          Function buildAce has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              buildAce() {
                return $(".ace-editor").each(function () {
                  if (!$(this).data("initialized")) {
                    const $this = $(this);
                    $this.data("initialized", true);
          Severity: Minor
          Found in app/assets/javascripts/pages/agent-edit-page.js - About 1 hr to fix

            Method form_configurable has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def form_configurable(name, *args)
                  options = args.extract_options!.reverse_merge(roles: [], type: :string)
            
                  if args.all?(Symbol)
                    options.assert_valid_keys([:type, :roles, :values, :ace, :cache_response, :html_options])
            Severity: Minor
            Found in app/concerns/form_configurable.rb - About 1 hr to fix

              Method receive has 34 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/weibo_publish_agent.rb - About 1 hr to fix

                Function showDynamicModal has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    static showDynamicModal(content, param) {
                      if (content == null) {
                        content = "";
                      }
                      if (param == null) {
                Severity: Minor
                Found in app/assets/javascripts/components/utils.js - About 1 hr to fix

                  Method receive_event has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def receive_event(event)
                        interpolate_with event do
                          messages_send = TELEGRAM_ACTIONS.count do |field, _method|
                            payload = event.payload[field]
                            next unless payload.present?
                  Severity: Minor
                  Found in app/models/agents/telegram_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 validate_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def validate_options
                        errors.add(:base, "username is required") unless options[:username].present?
                        errors.add(:base, "number is required") unless options[:number].present?
                        errors.add(:base, "history is required") unless options[:history].present?
                        errors.add(
                  Severity: Minor
                  Found in app/models/agents/twitter_favorites.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 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def receive(incoming_events)
                        tweets = tweets_from_events(incoming_events)
                  
                        begin
                          twitter.favorite(tweets) if favorite?
                  Severity: Minor
                  Found in app/models/agents/twitter_action_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 handle_data has 31 lines of code (exceeds 25 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 1 hr to fix

                    Function showCorrectRegionsOnStartup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        showCorrectRegionsOnStartup() {
                          if ($(".schedule-region")) {
                            if ($(".schedule-region").data("can-be-scheduled") === true) {
                              this.showSchedule();
                            } else {
                    Severity: Minor
                    Found in app/assets/javascripts/pages/agent-edit-page.js - About 1 hr to fix

                      Method schedule_scheduler_agent has 30 lines of code (exceeds 25 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
                        Severity
                        Category
                        Status
                        Source
                        Language