zammad/zammad

View on GitHub

Showing 4,240 of 4,240 total issues

Method perform has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
Open

  def perform

    # return if we run import mode
    return if Setting.get('import_mode')

Severity: Minor
Found in app/models/transaction/slack.rb - About 1 day 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 process_webhook has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
Open

  def process_webhook(channel)
    Rails.logger.debug { 'import tweet' }
    ticket = nil
    if @payload['direct_message_events'].present? && channel.options[:sync][:direct_messages][:group_id].present?
      @payload['direct_message_events'].each do |item|
Severity: Minor
Found in lib/twitter_sync.rb - About 1 day 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 load_data has 277 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.load_data(params)
    nice = params[:nice] || 0.5

    object_manager_attributes = params[:object_manager_attributes]
    agents                    = params[:agents] || 0
Severity: Major
Found in lib/fill_db.rb - About 1 day to fix

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

                if ( data.collisionWidth > outerWidth ) {
                    // element is initially over the left side of within
                    if ( overLeft > 0 && overRight <= 0 ) {
                        newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
                        position.left += overLeft - newOverRight;
    Severity: Major
    Found in app/assets/javascripts/app/lib/core/jquery-ui-1.11.4.js and 1 other location - About 1 day to fix
    app/assets/javascripts/app/lib/core/jquery-ui-1.11.4.js on lines 1404..1429

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

    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

                if ( data.collisionHeight > outerHeight ) {
                    // element is initially over the top of within
                    if ( overTop > 0 && overBottom <= 0 ) {
                        newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
                        position.top += overTop - newOverBottom;
    Severity: Major
    Found in app/assets/javascripts/app/lib/core/jquery-ui-1.11.4.js and 1 other location - About 1 day to fix
    app/assets/javascripts/app/lib/core/jquery-ui-1.11.4.js on lines 1367..1392

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

    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

    File qrcodegen.js has 624 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * QR Code generator library (compiled from TypeScript)
     *
     * Copyright (c) Project Nayuki. (MIT License)
     * https://www.nayuki.io/page/qr-code-generator-library
    Severity: Major
    Found in app/assets/javascripts/app/lib/base/qrcodegen.js - About 1 day to fix

      Method run has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.run(_channel, mail, _transaction_params)
      
          return if mail[:'x-zammad-ticket-id']
      
          # get ticket# from subject
      Severity: Minor
      Found in app/models/channel/filter/follow_up_check.rb - About 1 day 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

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

        it('supports icon property', async () => {
          const iconOptions = [
            {
              value: 1,
              label: 'GitLab',
      app/frontend/apps/desktop/components/Form/fields/FieldSelect/__tests__/FieldSelect.spec.ts on lines 290..325

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

      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

        it('supports icon property', async () => {
          const iconOptions = [
            {
              value: 1,
              label: 'GitLab',
      app/frontend/apps/desktop/components/Form/fields/FieldTreeSelect/__tests__/FieldTreeSelect.spec.ts on lines 554..589

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

      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

      File email_helper.rb has 615 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class EmailHelper
      
      =begin
      
      get available driver
      Severity: Major
      Found in lib/email_helper.rb - About 1 day to fix

        Method csv_example has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
        Open

            def csv_example(params = {})
              header = []
              records = where.not(id: csv_object_ids_ignored).offset(1).limit(23).to_a
              if records.count < 20
                record_ids = records.pluck(:id).concat(csv_object_ids_ignored)
        Severity: Minor
        Found in app/models/concerns/can_csv_import.rb - About 1 day 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 setDocument has 262 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        setDocument = Sizzle.setDocument = function( node ) {
            var hasCompare, subWindow,
                doc = node ? node.ownerDocument || node : preferredDoc;
        
            // Return early if doc is invalid or already selected
        Severity: Major
        Found in app/assets/javascripts/app/lib/core/jquery-3.6.0.js - About 1 day to fix

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

                      for (var y = 0; y < this.size; y++) {
                          var runColor = false;
                          var runX = 0;
                          var runHistory = [0, 0, 0, 0, 0, 0, 0];
                          for (var x = 0; x < this.size; x++) {
          Severity: Major
          Found in app/assets/javascripts/app/lib/base/qrcodegen.js and 1 other location - About 1 day to fix
          app/assets/javascripts/app/lib/base/qrcodegen.js on lines 428..449

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

          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

                      for (var x = 0; x < this.size; x++) {
                          var runColor = false;
                          var runY = 0;
                          var runHistory = [0, 0, 0, 0, 0, 0, 0];
                          for (var y = 0; y < this.size; y++) {
          Severity: Major
          Found in app/assets/javascripts/app/lib/base/qrcodegen.js and 1 other location - About 1 day to fix
          app/assets/javascripts/app/lib/base/qrcodegen.js on lines 405..426

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

          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

          File velocity.ui.js has 602 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /**********************
             Velocity UI Pack
          **********************/
          
          /* VelocityJS.org UI Pack (5.0.2). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License. Portions copyright Daniel Eden, Christian Pucci. */
          Severity: Major
          Found in app/assets/javascripts/app/lib/animations/velocity.ui.js - About 1 day to fix

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

                ZammadChat.prototype.loadCss = function() {
                  var newSS, styles, url;
                  if (!this.options.cssAutoload) {
                    return;
                  }
            Severity: Major
            Found in public/assets/chat/chat.js and 1 other location - About 1 day to fix
            public/assets/chat/chat-no-jquery.js on lines 2358..2375

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

            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

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

                ZammadChat.prototype.loadCss = function() {
                  var newSS, styles, url;
                  if (!this.options.cssAutoload) {
                    return;
                  }
            Severity: Major
            Found in public/assets/chat/chat-no-jquery.js and 1 other location - About 1 day to fix
            public/assets/chat/chat.js on lines 2325..2342

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

            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

            Function ajax has 259 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                ajax: function( url, options ) {
            
                    // If url is an object, simulate pre-1.5 signature
                    if ( typeof url === "object" ) {
                        options = url;
            Severity: Major
            Found in app/assets/javascripts/app/lib/core/jquery-3.6.0.js - About 1 day to fix

              Method associations_from_param has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
              Open

                def associations_from_param(params)
              
                  # special handling for group access association
                  {
                    groups:    :group_names_access_map=,
              Severity: Minor
              Found in app/models/application_model/can_associations.rb - About 1 day 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

              File jquery.textmodule.js has 580 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              (function ($, window, undefined) {
              
              /*
              # mode: textonly/richtext / disable b/i/u/enter + strip on paste
              # pasteOnlyText: true
              Severity: Major
              Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 1 day to fix
                Severity
                Category
                Status
                Source
                Language