zammad/zammad

View on GitHub

Showing 4,240 of 4,240 total issues

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

                plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis);
Severity: Major
Found in app/assets/javascripts/app/lib/flot/jquery.flot.js and 1 other location - About 1 hr to fix
app/assets/javascripts/app/lib/flot/jquery.flot.js on lines 1958..1958

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

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('implements disabled', async () => {
    const wrapper = renderComponent(FormKit, {
      ...wrapperParameters,
      props: {
        ...commonProps,
app/frontend/apps/desktop/components/Form/fields/FieldAutoComplete/__tests__/FieldAutoComplete.spec.ts on lines 1275..1288

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

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('implements disabled', async () => {
    const wrapper = renderComponent(FormKit, {
      ...wrapperParameters,
      props: {
        ...testProps,
app/frontend/apps/desktop/components/Form/fields/FieldSelect/__tests__/FieldSelect.spec.ts on lines 1394..1407

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

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 startTimeoutObservers has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    ZammadChat.prototype.startTimeoutObservers = function() {
      this.idleTimeout = new Timeout({
        logPrefix: 'idleTimeout',
        debug: this.options.debug,
        timeout: this.options.idleTimeout,
Severity: Minor
Found in public/assets/chat/chat.js - About 1 hr to fix

    Function startTimeoutObservers has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        ZammadChat.prototype.startTimeoutObservers = function() {
          this.idleTimeout = new Timeout({
            logPrefix: 'idleTimeout',
            debug: this.options.debug,
            timeout: this.options.idleTimeout,
    Severity: Minor
    Found in public/assets/chat/chat-no-jquery.js - About 1 hr to fix

      Function create has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        create(context) {
          const IGNORE_STRING_PATTERNS = [
            /^[^A-Z]/, // Only look at strings starting with upper case letters
            /\$\{/, // Ignore strings with interpolation
          ]

        Function showWidget has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            showWidget: function() {
              if (this.isOpen) {
                return;
              }
        
        
        Severity: Minor
        Found in app/assets/javascripts/app/lib/bootstrap/bootstrap-timepicker.js - About 1 hr to fix

          Function data has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              data: function( key, value ) {
                  var i, name, data,
                      elem = this[ 0 ],
                      attrs = elem && elem.attributes;
          
          
          Severity: Minor
          Found in app/assets/javascripts/app/lib/core/jquery-3.6.0.js - About 1 hr to fix

            Function leverageNative has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function leverageNative( el, type, expectSync ) {
            
                // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
                if ( !expectSync ) {
                    if ( dataPriv.get( el, type ) === undefined ) {
            Severity: Minor
            Found in app/assets/javascripts/app/lib/core/jquery-3.6.0.js - About 1 hr to fix

              Method url_check has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def url_check
                  return if setup_done_response
              
                  # validate
                  if params[:url].blank? || params[:url] !~ %r{^(http|https)://.+?$}
              Severity: Minor
              Found in app/controllers/import_zendesk_controller.rb - About 1 hr to fix

                Method link_account has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.link_account(_request_token, params)
                    #    fail if request_token.params[:oauth_token] != params[:state]
                    external_credential = ExternalCredential.find_by(name: 'facebook')
                    raise Exceptions::UnprocessableEntity, __('No Facebook app configured!') if !external_credential
                
                
                Severity: Minor
                Found in lib/external_credential/facebook.rb - About 1 hr to fix

                  Function useObjectAttributeFormData has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const useObjectAttributeFormData = (
                    objectAttributes: Map<string, ObjectManagerFrontendAttribute>,
                    values: FormValues,
                  ) => {
                    const internalObjectAttributeValues: Record<string, FormFieldValue> = {}

                    Function handleError has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      protected handleError(error: ApolloError): void {
                        const options = this.handlerOptions
                    
                        let triggerNotification = options.errorShowNotification
                    
                    
                    Severity: Minor
                    Found in app/frontend/shared/server/apollo/handler/BaseHandler.ts - About 1 hr to fix

                      Function debugLink has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const debugLink = new ApolloLink((operation, forward) => {
                        if (log.getLevel() < log.levels.DEBUG) return forward(operation)
                      
                        const requestContext = operation.getContext()
                      
                      
                      Severity: Minor
                      Found in app/frontend/shared/server/apollo/link/debug.ts - About 1 hr to fix

                        Function schema has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          definition.schema = (extensions) => {
                            let sectionSchemaExtension:
                              | FormKitSchemaCondition
                              | Partial<FormKitSchemaNode>
                        
                        
                        Severity: Minor
                        Found in app/frontend/shared/form/utils/extendSchemaDefinition.ts - About 1 hr to fix

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

                            def perform(model)
                              model = model.safe_constantize
                              return if model.blank?
                          
                              assets = {}
                          Severity: Minor
                          Found in app/jobs/collection_update_job.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 filter_matches? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def self.filter_matches?(mail, filter)
                          
                              min_one_rule_exists = false
                          
                              filter[:match].each do |key, meta|
                          Severity: Minor
                          Found in app/models/channel/filter/database.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 attachments_for_search_index_attribute_lookup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def attachments_for_search_index_attribute_lookup
                              # list ignored file extensions
                              attachments_ignore = Setting.get('es_attachment_ignore') || [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe' ]
                          
                              # max attachment size
                          Severity: Minor
                          Found in app/models/application_model/has_attachments.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 assets has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def assets(data)
                          
                                app_model_trigger = Trigger.to_app_model
                                data[ app_model_trigger ] ||= {}
                          
                          
                          Severity: Minor
                          Found in app/models/trigger/assets.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 changed? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def changed?(object:, current_changes:, previous_changes: {})
                                changed = false
                                previous_changes ||= {}
                                current_changes.each do |attribute, value|
                                  next if !object.attributes.key?(attribute.to_s)
                          Severity: Minor
                          Found in app/models/external_sync.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