discourse/discourse

View on GitHub

Showing 2,041 of 2,041 total issues

Function mparser has 1196 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var mparser = (function(){
    /*
     * Generated by PEG.js 0.7.0.
     *
     * http://pegjs.majda.cz/
Severity: Major
Found in lib/javascripts/messageformat.js - About 5 days to fix

    Function parse has 1151 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          parse: function(input, startRule) {
            var parseFunctions = {
              "start": parse_start,
              "messageFormatPattern": parse_messageFormatPattern,
              "messageFormatPatternRight": parse_messageFormatPatternRight,
    Severity: Major
    Found in lib/javascripts/messageformat.js - About 5 days to fix

      Function core has 1025 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      this.workbox.core = (function (exports) {
        'use strict';
      
        try {
          self['workbox:core:4.3.1'] && _();
      Severity: Major
      Found in public/javascripts/workbox/workbox-core.dev.js - About 5 days to fix

        Function core has a Cognitive Complexity of 214 (exceeds 5 allowed). Consider refactoring.
        Open

        this.workbox.core = (function (exports) {
          'use strict';
        
          try {
            self['workbox:core:4.3.1'] && _();
        Severity: Minor
        Found in public/javascripts/workbox/workbox-core.dev.js - About 4 days 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 messageformat.js has 1412 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * messageformat.js
         *
         * ICU PluralFormat + SelectFormat for JavaScript
         *
        Severity: Major
        Found in lib/javascripts/messageformat.js - About 3 days to fix

          Class User has 170 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class User < ActiveRecord::Base
            include Searchable
            include Roleable
            include HasCustomFields
            include SecondFactorManager
          Severity: Major
          Found in app/models/user.rb - About 3 days to fix

            File users_controller.rb has 1238 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class UsersController < ApplicationController
              skip_before_action :authorize_mini_profiler, only: [:avatar]
            
              requires_login only: [
                :username, :update, :user_preferences_redirect, :upload_user_image,
            Severity: Major
            Found in app/controllers/users_controller.rb - About 3 days to fix

              File user.rb has 1210 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class User < ActiveRecord::Base
                include Searchable
                include Roleable
                include HasCustomFields
                include SecondFactorManager
              Severity: Major
              Found in app/models/user.rb - About 3 days to fix

                File topic.rb has 1183 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                class Topic < ActiveRecord::Base
                  class UserExists < StandardError; end
                  include ActionView::Helpers::SanitizeHelper
                  include RateLimiter::OnCreateRecord
                  include HasCustomFields
                Severity: Major
                Found in app/models/topic.rb - About 3 days to fix

                  Function strategies has 586 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  this.workbox.strategies = (function (exports, logger_mjs, assert_mjs, cacheNames_mjs, cacheWrapper_mjs, fetchWrapper_mjs, getFriendlyURL_mjs, WorkboxError_mjs) {
                    'use strict';
                  
                    try {
                      self['workbox:strategies:4.3.1'] && _();
                  Severity: Major
                  Found in public/javascripts/workbox/workbox-strategies.dev.js - About 2 days to fix

                    File workbox-core.dev.js has 1029 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    this.workbox = this.workbox || {};
                    this.workbox.core = (function (exports) {
                      'use strict';
                    
                      try {
                    Severity: Major
                    Found in public/javascripts/workbox/workbox-core.dev.js - About 2 days to fix

                      File receiver.rb has 990 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require "digest"
                      
                      module Email
                      
                        class Receiver
                      Severity: Major
                      Found in lib/email/receiver.rb - About 2 days to fix

                        File pikaday.js has 972 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        /*!
                         * Pikaday
                         *
                         * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/Pikaday/Pikaday
                         */
                        Severity: Major
                        Found in public/javascripts/pikaday.js - About 2 days to fix

                          Function routing has 475 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          this.workbox.routing = (function (exports, assert_mjs, logger_mjs, cacheNames_mjs, WorkboxError_mjs, getFriendlyURL_mjs) {
                            'use strict';
                          
                            try {
                              self['workbox:routing:4.3.1'] && _();
                          Severity: Major
                          Found in public/javascripts/workbox/workbox-routing.dev.js - About 2 days to fix

                            Function strategies has a Cognitive Complexity of 115 (exceeds 5 allowed). Consider refactoring.
                            Open

                            this.workbox.strategies = (function (exports, logger_mjs, assert_mjs, cacheNames_mjs, cacheWrapper_mjs, fetchWrapper_mjs, getFriendlyURL_mjs, WorkboxError_mjs) {
                              'use strict';
                            
                              try {
                                self['workbox:strategies:4.3.1'] && _();
                            Severity: Minor
                            Found in public/javascripts/workbox/workbox-strategies.dev.js - About 2 days 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 3 locations. Consider refactoring.
                            Open

                                      if (result0 !== null) {
                                        if (input.substr(pos, 6) === "offset") {
                                          result1 = "offset";
                                          pos += 6;
                                        } else {
                            Severity: Major
                            Found in lib/javascripts/messageformat.js and 2 other locations - About 2 days to fix
                            lib/javascripts/messageformat.js on lines 423..480
                            lib/javascripts/messageformat.js on lines 497..554

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

                            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 (result0 !== null) {
                                        if (input.substr(pos, 6) === "plural") {
                                          result1 = "plural";
                                          pos += 6;
                                        } else {
                            Severity: Major
                            Found in lib/javascripts/messageformat.js and 2 other locations - About 2 days to fix
                            lib/javascripts/messageformat.js on lines 497..554
                            lib/javascripts/messageformat.js on lines 658..715

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

                            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 (result0 !== null) {
                                          if (input.substr(pos, 6) === "select") {
                                            result1 = "select";
                                            pos += 6;
                                          } else {
                            Severity: Major
                            Found in lib/javascripts/messageformat.js and 2 other locations - About 2 days to fix
                            lib/javascripts/messageformat.js on lines 423..480
                            lib/javascripts/messageformat.js on lines 658..715

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

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

                            class Search
                              DIACRITICS ||= /([\u0300-\u036f]|[\u1AB0-\u1AFF]|[\u1DC0-\u1DFF]|[\u20D0-\u20FF])/
                            
                              cattr_accessor :preloaded_topic_custom_fields
                              self.preloaded_topic_custom_fields = Set.new
                            Severity: Major
                            Found in lib/search.rb - About 2 days to fix

                              File topic_query.rb has 850 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              class TopicQuery
                                PG_MAX_INT ||= 2147483647
                              
                                def self.validators
                                  @validators ||= begin
                              Severity: Major
                              Found in lib/topic_query.rb - About 2 days to fix
                                Severity
                                Category
                                Status
                                Source
                                Language