cantino/huginn

View on GitHub

Showing 177 of 177 total issues

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

        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

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

                  if ($(".control-link-region")) {
                    if (
                      $(".control-link-region").data("can-control-other-agents") === true
                    ) {
                      this.showControlLinks();
            Severity: Major
            Found in app/assets/javascripts/pages/agent-edit-page.js and 2 other locations - About 1 hr to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 234..240
            app/assets/javascripts/pages/agent-edit-page.js on lines 242..248

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

            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 3 locations. Consider refactoring.
            Open

                  if ($(".schedule-region")) {
                    if ($(".schedule-region").data("can-be-scheduled") === true) {
                      this.showSchedule();
                    } else {
                      this.hideSchedule();
            Severity: Major
            Found in app/assets/javascripts/pages/agent-edit-page.js and 2 other locations - About 1 hr to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 242..248
            app/assets/javascripts/pages/agent-edit-page.js on lines 250..258

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

            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 3 locations. Consider refactoring.
            Open

                  if ($(".link-region")) {
                    if ($(".link-region").data("can-receive-events") === true) {
                      this.showLinks();
                    } else {
                      this.hideLinks();
            Severity: Major
            Found in app/assets/javascripts/pages/agent-edit-page.js and 2 other locations - About 1 hr to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 234..240
            app/assets/javascripts/pages/agent-edit-page.js on lines 250..258

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

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

                  Severity
                  Category
                  Status
                  Source
                  Language