moebooru/moebooru

View on GitHub

Showing 370 of 8,198 total issues

Class PostController has 32 methods (exceeds 20 allowed). Consider refactoring.
Open

class PostController < ApplicationController
  layout "default"
  helper :avatar

  before_action :member_only, :only => [:create, :destroy, :delete, :flag, :revert_tags, :activate, :update_batch, :vote]
Severity: Minor
Found in app/controllers/post_controller.rb - About 4 hrs to fix

    Method print_preview has 99 lines of code (exceeds 25 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: Major
    Found in app/helpers/post_helper.rb - About 3 hrs to fix

      Class UserController has 31 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class UserController < ApplicationController
        layout "default"
        before_action :blocked_only, :only => [:authenticate, :update, :edit, :modify_blacklist]
        before_action :janitor_only, :only => [:invites]
        before_action :mod_only, :only => [:block, :unblock, :show_blocked_users]
      Severity: Minor
      Found in app/controllers/user_controller.rb - About 3 hrs to fix

        Function Sizzle has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var Sizzle = function(selector, context, results, seed) {
            results = results || [];
            var origContext = context = context || document;
        
            if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
        Severity: Major
        Found in lib/assets/javascripts/prototype/prototype.js - About 3 hrs to fix

          Function start has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            start: function(options) {
              if (options && options.transition === false) options.transition = Effect.Transitions.linear;
              this.options      = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
              this.currentFrame = 0;
              this.state        = 'idle';
          Severity: Minor
          Found in lib/assets/javascripts/prototype/effects.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

          Function Class has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

          var Class = (function() {
          
            var IS_DONTENUM_BUGGY = (function(){
              for (var p in { toString: 1 }) {
                if (p === 'toString') return false;
          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 resize has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              def resize(file_ext, input_path, output_path, output_size, output_quality)
                input_image = Moebooru::ImageSizeExif.path(input_path)
          
                colorspace = input_image[:colorspace]
          
          
          Severity: Minor
          Found in lib/moebooru/resizer.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 Hash has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var Hash = Class.create(Enumerable, (function() {
            function initialize(object) {
              this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
            }
          
          
          Severity: Major
          Found in lib/assets/javascripts/prototype/prototype.js - About 3 hrs to fix

            File history_helper.rb has 321 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            Severity: Minor
            Found in app/helpers/history_helper.rb - About 3 hrs to fix

              Function update has 92 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                update: (function(){
              
                  var SELECT_ELEMENT_INNERHTML_BUGGY = (function(){
                    var el = document.createElement("select"),
                        isBuggy = true;
              Severity: Major
              Found in lib/assets/javascripts/prototype/prototype.js - About 3 hrs to fix

                File user_controller.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                class UserController < ApplicationController
                  layout "default"
                  before_action :blocked_only, :only => [:authenticate, :update, :edit, :modify_blacklist]
                  before_action :janitor_only, :only => [:invites]
                  before_action :mod_only, :only => [:block, :unblock, :show_blocked_users]
                Severity: Minor
                Found in app/controllers/user_controller.rb - About 3 hrs to fix

                  Method moderate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def moderate
                      if request.post?
                        posts = []
                  
                        Post.transaction do
                  Severity: Minor
                  Found in app/controllers/post_controller.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

                  Method commit_tags has 88 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def commit_tags
                      return if new_tags.nil?
                  
                      if old_tags
                        # If someone else committed changes to this post before we did,
                  Severity: Major
                  Found in app/models/post/tag_methods.rb - About 3 hrs to fix

                    Class InlineImage has 29 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class InlineImage < ApplicationRecord
                      belongs_to :inline
                      before_validation :download_source, :on => :create
                      before_validation :determine_content_type, :on => :create
                      before_validation :set_image_dimensions, :on => :create
                    Severity: Minor
                    Found in app/models/inline_image.rb - About 3 hrs to fix

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

                        create: function(element) {
                          element = $(element);
                          var options = Object.extend({
                            element:     element,
                            tag:         'li',       // assumes li children, override with tag: 'tagname'
                      Severity: Major
                      Found in lib/assets/javascripts/prototype/dragdrop.js - About 3 hrs to fix

                        Method index has 86 lines of code (exceeds 25 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: Major
                        Found in app/controllers/post_controller.rb - About 3 hrs to fix

                          File sql_methods.rb has 307 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          module Post::SqlMethods
                            module ClassMethods
                              def find_by_tag_join(tag, options = {})
                                joins(:_tags).where(:tags => { :name => tag.downcase.tr(" ", "_") })
                                  .limit(options[:limit])
                          Severity: Minor
                          Found in app/models/post/sql_methods.rb - About 3 hrs to fix

                            Class Artist has 28 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            class Artist < ApplicationRecord
                              module UrlMethods
                                module ClassMethods
                                  def find_all_by_url(url)
                                    url = ArtistUrl.normalize(url)
                            Severity: Minor
                            Found in app/models/artist.rb - About 3 hrs to fix

                              Function initialize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                              Open

                                initialize: function(testcases) {
                                  this.options = Object.extend({
                                    testLog: 'testlog'
                                  }, arguments[1] || {});
                                  this.options.resultsURL = this.parseResultsURLQueryParameter();
                              Severity: Minor
                              Found in lib/assets/javascripts/prototype/unittest.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 search has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def search(params)
                                    options = params.merge(
                                      :services => @services
                                    )
                              
                              
                              Severity: Minor
                              Found in app/controllers/post_controller.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

                              Severity
                              Category
                              Status
                              Source
                              Language