moebooru/moebooru

View on GitHub

Showing 370 of 8,198 total issues

Method diff has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

Severity: Minor
Found in lib/danbooru.rb - About 3 hrs 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 application_controller.rb has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ApplicationController < ActionController::Base
  protect_from_forgery
  rescue_from ActiveRecord::StatementInvalid, :with => :rescue_pg_invalid_query
  before_action :filter_spam
  before_action :set_locale
Severity: Minor
Found in app/controllers/application_controller.rb - About 3 hrs to fix

    Class Post has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Post < ApplicationRecord
      STATUSES = %w(active pending flagged deleted)
    
      define_callbacks :delete
      define_callbacks :undelete
    Severity: Minor
    Found in app/models/post.rb - About 3 hrs to fix

      Function getStyle has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        Element.Methods.getStyle = function(element, style) {
          element = $(element);
          style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
          var value = element.style[style];
          if (!value && element.currentStyle) value = element.currentStyle[style];
      Severity: Minor
      Found in lib/assets/javascripts/prototype/prototype.js - About 3 hrs 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 get_zip_data has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_zip_data(options = {})
            return [] if pool_posts.empty?
      
            jpeg = options[:jpeg] || false
      
      
      Severity: Minor
      Found in app/models/pool.rb - About 3 hrs 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 addMethods has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Element.addMethods = function(methods) {
        var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
      
        if (!methods) {
          Object.extend(Form, Form.Methods);
      Severity: Major
      Found in lib/assets/javascripts/prototype/prototype.js - About 3 hrs to fix

        Function _attributeTranslations has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          Element._attributeTranslations = (function(){
        
            var classProp = 'className',
                forProp = 'for',
                el = document.createElement('div');
        Severity: Major
        Found in lib/assets/javascripts/prototype/prototype.js - About 3 hrs to fix

          Function Enumerable has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          var Enumerable = (function() {
            function each(iterator, context) {
              var index = 0;
              try {
                this._each(function(value) {
          Severity: Minor
          Found in lib/assets/javascripts/prototype/prototype.js - About 2 hrs 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 pretty_data has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

            def pretty_data
              case task_type
              when "mass_tag_edit"
                start = data["start_tags"]
                result = data["result_tags"]
          Severity: Minor
          Found in app/models/job_task.rb - About 2 hrs 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 format_changes has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Severity: Major
          Found in app/helpers/history_helper.rb - About 2 hrs to fix

            Function _attributeTranslations has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              Element._attributeTranslations = (function(){
            
                var classProp = 'className',
                    forProp = 'for',
                    el = document.createElement('div');
            Severity: Minor
            Found in lib/assets/javascripts/prototype/prototype.js - About 2 hrs 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 extend has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            Element.extend = (function() {
            
              function checkDeficiency(tagName) {
                if (typeof window.Element != 'undefined') {
                  var proto = window.Element.prototype;
            Severity: Minor
            Found in lib/assets/javascripts/prototype/prototype.js - About 2 hrs 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 startDrag has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              startDrag: function(event) {
                if (Event.isLeftClick(event)) {
                  if (!this.disabled){
                    this.active = true;
            
            
            Severity: Minor
            Found in lib/assets/javascripts/prototype/slider.js - About 2 hrs 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 copy_file_to_mirrors has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              def copy_file_to_mirrors(file, options = {})
                # CONFIG[:data_dir] is equivalent to our local_base.
                local_base = "#{Rails.root}/public/data/"
                options = { :timeout => 30 }.merge(options)
            
            
            Severity: Minor
            Found in lib/mirrors.rb - About 2 hrs 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 pool.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            include ERB::Util
            
            class Pool < ApplicationRecord
              belongs_to :user
              validates_presence_of :name
            Severity: Minor
            Found in app/models/pool.rb - About 2 hrs to fix

              Function Grow has 68 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Effect.Grow = function(element) {
                element = $(element);
                var options = Object.extend({
                  direction: 'center',
                  moveTransition: Effect.Transitions.sinoidal,
              Severity: Major
              Found in lib/assets/javascripts/prototype/effects.js - About 2 hrs to fix

                InPlaceEditor has 24 functions (exceeds 20 allowed). Consider refactoring.
                Open

                Ajax.InPlaceEditor = Class.create({
                  initialize: function(element, url, options) {
                    this.url = url;
                    this.element = element = $(element);
                    this.prepareOptions();
                Severity: Minor
                Found in lib/assets/javascripts/prototype/controls.js - About 2 hrs to fix

                  Class Pool has 24 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Pool < ApplicationRecord
                    belongs_to :user
                    validates_presence_of :name
                  
                    class PostAlreadyExistsError < Exception
                  Severity: Minor
                  Found in app/models/pool.rb - About 2 hrs to fix

                    Class ForumPost has 24 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class ForumPost < ApplicationRecord
                      belongs_to :creator, :class_name => "User", :foreign_key => :creator_id
                      belongs_to :updater, :class_name => "User", :foreign_key => :last_updated_by
                      after_create :initialize_last_updated_by
                      after_create :clear_cache
                    Severity: Minor
                    Found in app/models/forum_post.rb - About 2 hrs to fix

                      Class ApplicationController has 24 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class ApplicationController < ActionController::Base
                        protect_from_forgery
                        rescue_from ActiveRecord::StatementInvalid, :with => :rescue_pg_invalid_query
                        before_action :filter_spam
                        before_action :set_locale
                      Severity: Minor
                      Found in app/controllers/application_controller.rb - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language