hummingbird-me/hummingbird

View on GitHub

Showing 859 of 859 total issues

Avoid deeply nested control flow statements.
Open

                            if (lookAhead("'")) {
                                output += "'";
                            } else {
                                literal = true;
                            }
Severity: Major
Found in app/assets/javascripts/old/jquery-ui-custom-1.10.3.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            switch (col) {
                                case 0: calender += " ui-datepicker-group-first";
                                    cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
                                case numMonths[1]-1: calender += " ui-datepicker-group-last";
                                    cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
    Severity: Major
    Found in app/assets/javascripts/old/jquery-ui-custom-1.10.3.js - About 45 mins to fix

      Function avatar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export function avatar(user, size) {
        var avatarUrl = user.get("avatarTemplate").replace('{size}', size);
        if (size !== "thumb") {
          const pattern = /\.[a-zA-Z]+\?/;
          // handle Facebook/weird case
      Severity: Minor
      Found in frontend/app/helpers/avatar.js - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

                if(data) { data.key = key; }
      Severity: Major
      Found in app/assets/javascripts/old/handlebars-1.0.0.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (this.terminals_[p] && p > 2) {
                                expected.push("'" + this.terminals_[p] + "'");
                            }
        Severity: Major
        Found in app/assets/javascripts/old/handlebars-1.0.0.js - About 45 mins to fix

          Function invokePartial has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            invokePartial: function(partial, name, context, helpers, partials, data) {
          Severity: Minor
          Found in app/assets/javascripts/old/handlebars-1.0.0.js - About 45 mins to fix

            Function franchiseAnime has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              franchiseAnime: function() {
                var anime = [];
                this.getEach("anime").forEach(function(animeSet) {
                  anime = anime.concat(animeSet.toArray());
                });
            Severity: Minor
            Found in frontend/app/controllers/franchises.js - About 45 mins 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                return error! "Invalid message type", 400 unless params[:type].in?(['message', 'action', 'notice', nil])
                return error! "Message is required", 400 unless params.has_key?(:message)
                return error! "Not an administrator", 403 if params[:type] == 'notice' && !current_user.admin?
                return error! "User is banned", 403 if current_user.ninja_banned?
            Severity: Minor
            Found in app/controllers/chats_controller.rb - About 45 mins 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 destroy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def destroy
                return error! "Mods can only remove regular users from the group", 403 unless current_user.admin? || current_member.admin? || (current_member.mod? && membership.pleb?) || current_user.id == membership.user_id
                return error! "You must promote another admin", 400 if membership.admin? && !group.can_admin_resign?
                return error! "Wrong user", 403 if current_member.pleb? && current_user.id != membership.user_id
            
            
            Severity: Minor
            Found in app/controllers/group_members_controller.rb - About 45 mins 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                params.permit(:token, :plan_id, :gift, :gift_to, :gift_message)
            
                if params[:token].blank?
                  return render(text: "Didn't get credit card details from Stripe", status: 400)
            Severity: Minor
            Found in app/controllers/pro_memberships_controller.rb - About 45 mins 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 embed_media has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def embed_media
                html = Nokogiri::HTML.fragment(@processed)
                html.css("a").each do |a|
                  href = a["href"]
                  next if href =~ IMAGE_REGEX && filesize(href) > MAX_IMAGE_FILE_SIZE
            Severity: Minor
            Found in app/services/message_formatter.rb - About 45 mins 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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def index
                if params[:followed_by] || params[:followers_of]
                  if params[:followed_by]
                    users = User.find(params[:followed_by]).following
                  elsif params[:followers_of]
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 45 mins 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                authenticate_user!
            
                user = User.find(params[:id])
                changes = params[:current_user] || params[:user]
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 45 mins 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 create_or_update_from_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.create_or_update_from_hash(hash)
                person = Person.create_or_update_from_hash(hash) unless hash[:name].blank?
            
                if hash[:character] ### Voice Actor
                  # TODO: overwrite castings when adding the first voice actor if there's already a casting
            Severity: Minor
            Found in app/models/casting.rb - About 45 mins 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 each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def each
                status_map = "ListImport::MyAnimeList::#{@media_type.upcase}_STATUS_MAP".constantize
                @data.each do |row|
                  mal_id = (row['series_animedb_id'] || row['manga_mangadb_id']).to_i
                  media = @db.where(mal_id: mal_id).first
            Severity: Minor
            Found in lib/list_imports/myanimelist.rb - About 45 mins 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 recompute_bayesian_ratings! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def recompute_bayesian_ratings!
                  #
                  # Bayesian rating:
                  #
                  #     r * v / (v + m) + c * m / (v + m)
            Severity: Minor
            Found in app/models/concerns/bayesian_averageable.rb - About 45 mins 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 create_or_update_from_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.create_or_update_from_hash(hash)
                character = Character.find_by(mal_id: hash[:external_id])
            
                # NOTE: Ideally we'd find by name+series but that doesn't seem possible
                # Should we name+role?
            Severity: Minor
            Found in app/models/character.rb - About 45 mins 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 4 locations. Consider refactoring.
            Open

                if (this.get("romajiTitle") && this.get("romajiTitle").length > 0) {
                  str += this.get("romajiTitle");
                }
            Severity: Major
            Found in frontend/app/models/manga.js and 3 other locations - About 45 mins to fix
            frontend/app/models/anime.js on lines 50..52
            frontend/app/models/anime.js on lines 53..55
            frontend/app/models/manga.js on lines 27..29

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

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

                if (this.get('romajiTitle') && this.get('romajiTitle').length > 0) {
                  str += this.get('romajiTitle');
                }
            Severity: Major
            Found in frontend/app/models/anime.js and 3 other locations - About 45 mins to fix
            frontend/app/models/anime.js on lines 50..52
            frontend/app/models/manga.js on lines 27..29
            frontend/app/models/manga.js on lines 30..32

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

            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

                if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
                    return $.datepicker["_" + options + "Datepicker"].
                        apply($.datepicker, [this[0]].concat(otherArgs));
                }
            Severity: Minor
            Found in app/assets/javascripts/old/jquery-ui-custom-1.10.3.js and 1 other location - About 45 mins to fix
            app/assets/javascripts/old/jquery-ui-custom-1.10.3.js on lines 8814..8817

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

            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