moebooru/moebooru

View on GitHub

Showing 370 of 8,198 total issues

Method undo has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

  def self.undo(changes, user, redo_change = false, errors = {})
    # Save parent objects after child objects, so changes to the children are
    # committed when we save the parents.
    objects = {}

Severity: Minor
Found in app/models/history.rb - About 6 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

Methods has 48 functions (exceeds 20 allowed). Consider refactoring.
Open

Element.Methods = {
  visible: function(element) {
    return $(element).style.display != 'none';
  },

Severity: Minor
Found in lib/assets/javascripts/prototype/prototype.js - About 6 hrs to fix

    Method similar_images has 162 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def similar_images(options = {})
        errors = {}
    
        local_service = CONFIG["local_image_service"]
    
    
    Severity: Major
    Found in lib/similar_images.rb - About 6 hrs to fix

      Method print_preview has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

        def print_preview(post, options = {})
          is_post = post.instance_of?(Post)
          if is_post && !CONFIG["can_see_post"].call(@current_user, post)
            return ""
          end
      Severity: Minor
      Found in app/helpers/post_helper.rb - About 6 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 index has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          search = params[:search] || ""
      
          q = Hash.new { |h, k| h[k] = [] }
      
      
      Severity: Minor
      Found in app/controllers/history_controller.rb - About 6 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 node has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

        node: function(elementName) {
          elementName = elementName.toUpperCase();
      
          // try innerHTML approach
          var parentTag = this.NODEMAP[elementName] || 'div';
      Severity: Minor
      Found in lib/assets/javascripts/prototype/builder.js - About 5 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 update has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

        update: (function(){
      
          var SELECT_ELEMENT_INNERHTML_BUGGY = (function(){
            var el = document.createElement("select"),
                isBuggy = true;
      Severity: Minor
      Found in lib/assets/javascripts/prototype/prototype.js - About 5 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 file_methods.rb has 397 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Post::FileMethods
        def self.included(m)
          m.before_validation :download_source, :on => :create
          m.before_validation :ensure_tempfile_exists, :on => :create
          m.before_validation :determine_content_type, :on => :create
      Severity: Minor
      Found in app/models/post/file_methods.rb - About 5 hrs to fix

        Function Serializers has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

        Form.Element.Serializers = (function() {
          function input(element, value) {
            switch (element.type.toLowerCase()) {
              case 'checkbox':
              case 'radio':
        Severity: Minor
        Found in lib/assets/javascripts/prototype/prototype.js - About 5 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 a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

        Element.addMethods = function(methods) {
          var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
        
          if (!methods) {
            Object.extend(Form, Form.Methods);
        Severity: Minor
        Found in lib/assets/javascripts/prototype/prototype.js - About 4 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 index has 121 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def index
            search = params[:search] || ""
        
            q = Hash.new { |h, k| h[k] = [] }
        
        
        Severity: Major
        Found in app/controllers/history_controller.rb - About 4 hrs to fix

          Method parse_query has 113 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def parse_query(query, options = {})
                q = Hash.new { |h, k| h[k] = [] }
          
                scan_query(query).each do |token|
                  if token =~ /^([qse])$/
          Severity: Major
          Found in app/models/tag/parse_methods.rb - About 4 hrs to fix

            Method create has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                if @current_user.is_member_or_lower? && Post.where(:user_id => @current_user.id).where("created_at > ?", 1.day.ago).count >= CONFIG["member_post_limit"]
                  respond_to_error("Daily limit exceeded", { :action => "error" }, :status => 421)
                  return
                end
            Severity: Minor
            Found in app/controllers/post_controller.rb - About 4 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 init_cookies has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

              def init_cookies
                return if params[:format] == "xml" || params[:format] == "json"
            
                cookies["forum_post_last_read_at"] = if @current_user.is_anonymous?
                                                       Time.now
            Severity: Minor
            Found in app/controllers/application_controller.rb - About 4 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 index has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

              def index
                params[:tags] = Tag.scan_query(params[:tags]).join(" ").presence
                tags = params[:tags]
                split_tags = QueryParser.parse(tags)
                page = page_number
            Severity: Minor
            Found in app/controllers/post_controller.rb - About 4 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 select_image_server has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                def select_image_server(is_warehoused, seed = 0, options = {})
                  return CONFIG["url_base"] if !CONFIG["image_servers"] || CONFIG["image_servers"].empty?
                  raise 'CONFIG["url_base"] is set incorrectly; please see config/default_config.rb' if CONFIG["image_servers"][0].class == String
            
                  unless is_warehoused
            Severity: Minor
            Found in lib/mirrors.rb - About 4 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

            prototype has 33 functions (exceeds 20 allowed). Consider refactoring.
            Open

            Test.Unit.Assertions.prototype = {
              initialize: function() {
                this.assertions = 0;
                this.failures   = 0;
                this.errors     = 0;
            Severity: Minor
            Found in lib/assets/javascripts/prototype/unittest.js - About 4 hrs to fix

              File pool_controller.rb has 339 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class PoolController < ApplicationController
                layout "default"
                before_action :member_only, :only => [:destroy, :update, :add_post, :remove_post, :import, :zip]
                before_action :post_member_only, :only => [:create]
                before_action :contributor_only, :only => [:copy, :transfer_metadata]
              Severity: Minor
              Found in app/controllers/pool_controller.rb - About 4 hrs to fix

                Function setOptions has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                  setOptions: function(options) {
                    this.options = Object.extend({
                      choices: 10,
                      partialSearch: true,
                      partialChars: 2,
                Severity: Minor
                Found in lib/assets/javascripts/prototype/controls.js - About 4 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 index has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                  def index
                    @pools = Pool.all
                    options = {
                      :per_page => 20,
                      :page => page_number
                Severity: Minor
                Found in app/controllers/pool_controller.rb - About 4 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

                Severity
                Category
                Status
                Source
                Language