zammad/zammad

View on GitHub

Showing 2,501 of 2,501 total issues

File attribute.rb has 832 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ObjectManager::Attribute < ApplicationModel
  include HasDefaultModelUserRelations

  include ChecksClientNotification
  include CanSeed
Severity: Major
Found in app/models/object_manager/attribute.rb - About 2 days to fix

    Method csv_import has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
    Open

        def csv_import(data)
          try    = data[:try].to_s == 'true'
          delete = data[:delete].to_s == 'true'
    
          begin
    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

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

    export type CurrentUserAttributesFragment = { __typename?: 'User', email?: string | null, id: string, internalId: number, firstname?: string | null, lastname?: string | null, fullname?: string | null, image?: string | null, preferences?: any | null, hasSecondaryOrganizations?: boolean | null, permissions?: { __typename?: 'UserPermission', names: Array<string> } | null, objectAttributeValues?: Array<{ __typename?: 'ObjectAttributeValue', value?: any | null, renderedLink?: string | null, attribute: { __typename?: 'ObjectManagerFrontendAttribute', name: string, display: string } }> | null, organization?: { __typename?: 'Organization', id: string, internalId: number, name?: string | null, active?: boolean | null, objectAttributeValues?: Array<{ __typename?: 'ObjectAttributeValue', value?: any | null, renderedLink?: string | null, attribute: { __typename?: 'ObjectManagerFrontendAttribute', name: string, display: string } }> | null } | null };
    Severity: Major
    Found in app/frontend/shared/graphql/types.ts and 1 other location - About 1 day to fix
    app/frontend/shared/graphql/types.ts on lines 3922..3922

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

    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

    export type CurrentUserQuery = { __typename?: 'Queries', currentUser: { __typename?: 'User', email?: string | null, id: string, internalId: number, firstname?: string | null, lastname?: string | null, fullname?: string | null, image?: string | null, preferences?: any | null, hasSecondaryOrganizations?: boolean | null, permissions?: { __typename?: 'UserPermission', names: Array<string> } | null, objectAttributeValues?: Array<{ __typename?: 'ObjectAttributeValue', value?: any | null, renderedLink?: string | null, attribute: { __typename?: 'ObjectManagerFrontendAttribute', name: string, display: string } }> | null, organization?: { __typename?: 'Organization', id: string, internalId: number, name?: string | null, active?: boolean | null, objectAttributeValues?: Array<{ __typename?: 'ObjectAttributeValue', value?: any | null, renderedLink?: string | null, attribute: { __typename?: 'ObjectManagerFrontendAttribute', name: string, display: string } }> | null } | null } };
    Severity: Major
    Found in app/frontend/shared/graphql/types.ts and 1 other location - About 1 day to fix
    app/frontend/shared/graphql/types.ts on lines 3869..3869

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

    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 association_name_to_id_convert has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
    Open

        def association_name_to_id_convert(params)
    
          if params.respond_to?(:permit!)
            params = params.permit!.to_h
          end
    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 email_parser.rb has 762 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Channel::EmailParser
      include Channel::EmailHelper
    
      PROCESS_TIME_MAX = 180
      EMAIL_REGEX = %r{.+@.+}
    Severity: Major
    Found in app/models/channel/email_parser.rb - About 1 day to fix

      File twitter_sync.rb has 762 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'http/uri'
      
      class TwitterSync
      
        STATUS_URL_TEMPLATE = 'https://twitter.com/_/status/%s'.freeze
      Severity: Major
      Found in lib/twitter_sync.rb - About 1 day to fix

        File search_index_backend.rb has 758 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class SearchIndexBackend
        
          SUPPORTED_ES_VERSION_MINIMUM   = '7.8'.freeze
          SUPPORTED_ES_VERSION_LESS_THAN = '9'.freeze
        
        
        Severity: Major
        Found in lib/search_index_backend.rb - About 1 day to fix

          File guided-setup-manual-channel-email.spec.ts has 727 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
          
          import { getNode } from '@formkit/core'
          import {
            getByLabelText,

            Method condition_query has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
            Open

              def condition_query(block_condition)
                query_must     = []
                query_must_not = []
            
                current_user = options[:current_user]
            Severity: Minor
            Found in lib/selector/search_index.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('can show inbound configuration form when roundtrip is unsuccessful', async () => {
                  const view = await visitView('/guided-setup/manual/channels/email')
            
                  const accountForm = view.getByTestId('channel-email-account')
            
            
            app/frontend/apps/desktop/pages/guided-setup/__tests__/guided-setup-manual-channel-email.spec.ts on lines 502..560

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

            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('can show outbound configuration form when roundtrip is unsuccessful', async () => {
                  const view = await visitView('/guided-setup/manual/channels/email')
            
                  const accountForm = view.getByTestId('channel-email-account')
            
            
            app/frontend/apps/desktop/pages/guided-setup/__tests__/guided-setup-manual-channel-email.spec.ts on lines 235..290

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

            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 users_controller.rb has 698 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class UsersController < ApplicationController
              include ChecksUserAttributesByCurrentUserPermission
              include CanPaginate
            
              prepend_before_action -> { authorize! }, only: %i[import_example import_start search history unlock]
            Severity: Major
            Found in app/controllers/users_controller.rb - About 1 day to fix

              Method config has 303 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.config
                  config = {}
                  config[:metric] = {}
              
                  config[:metric][:count] = {
              Severity: Major
              Found in app/models/report.rb - About 1 day to fix

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

                  def perform
                
                    # return if we run import mode
                    return if Setting.get('import_mode')
                    return if @item[:object] != 'Ticket'
                Severity: Minor
                Found in app/models/transaction/notification.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 fill_db.rb has 666 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module FillDb
                
                =begin
                
                fill your database with demo records
                Severity: Major
                Found in lib/fill_db.rb - About 1 day to fix

                  Function useTicketEditForm has 288 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const useTicketEditForm = (
                    ticket: Ref<TicketById | undefined>,
                    form: Ref<FormRef | undefined>,
                  ) => {
                    const ticketArticleTypes = computed(() => {
                  Severity: Major
                  Found in app/frontend/apps/mobile/pages/ticket/composable/useTicketEditForm.ts - About 1 day to fix

                    File telegram_helper.rb has 645 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require 'telegram/bot'
                    
                    class TelegramHelper
                    
                      attr_accessor :client
                    Severity: Major
                    Found in lib/telegram_helper.rb - About 1 day to fix

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

                        it('supports clearing of the existing value when option goes away', async () => {
                          const optionsProp = cloneDeep(testOptions)
                      
                          optionsProp.push({
                            value: 10,
                      app/frontend/apps/desktop/components/Form/fields/FieldSelect/__tests__/FieldSelect.spec.ts on lines 173..207

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

                      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 clearing of the existing value when option goes away', async () => {
                          const optionsProp = cloneDeep(testOptions)
                      
                          optionsProp.push({
                            value: 3,
                      app/frontend/apps/desktop/components/Form/fields/FieldTreeSelect/__tests__/FieldTreeSelect.spec.ts on lines 366..400

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language