cantino/huginn

View on GitHub

Showing 177 of 177 total issues

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

Function map_marker has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

window.map_marker = function (map, options) {
  let marker;
  if (options == null) {
    options = {};
  }
Severity: Minor
Found in app/assets/javascripts/map_marker.js - About 1 hr to fix

    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

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

                success: (data) => {
                  form_group.addClass("has-feedback").removeClass("has-error");
                  form_group.find("span").addClass("hidden");
                  form_group.find(".glyphicon-ok").removeClass("hidden");
                },
      Severity: Major
      Found in app/assets/javascripts/components/form_configurable.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/components/form_configurable.js on lines 24..28

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

      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

                error: (data) => {
                  form_group.addClass("has-feedback").addClass("has-error");
                  form_group.find("span").addClass("hidden");
                  form_group.find(".glyphicon-remove").removeClass("hidden");
                },
      Severity: Major
      Found in app/assets/javascripts/components/form_configurable.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/components/form_configurable.js on lines 19..23

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

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

                    Severity
                    Category
                    Status
                    Source
                    Language