moebooru/moebooru

View on GitHub

Showing 370 of 8,198 total issues

Method get_zip_control_file has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def get_zip_control_file(options = {})
      return "" if pool_posts.empty?

      jpeg = options[:jpeg] || false

Severity: Minor
Found in app/models/pool.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 generate_sample has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def generate_sample(force_regen = false)
    return true unless image?
    return true unless CONFIG["image_samples"]
    return true unless width && height
    return true if (file_ext.downcase == "gif")
Severity: Minor
Found in app/models/post/file_methods.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 update_batch has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def update_batch
    user_id = @current_user.id

    ids = {}
    (params["post"] || []).each do |key_or_value, value|
Severity: Minor
Found in app/controllers/post_controller.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

Base has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

Autocompleter.Base = Class.create({
  baseInitialize: function(element, update, options) {
    element          = $(element);
    this.element     = element;
    this.update      = $(update);
Severity: Minor
Found in lib/assets/javascripts/prototype/controls.js - About 2 hrs to fix

    Method api_attributes has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def api_attributes
        ret = {
          :id => id,
          :tags => cached_tags,
          :created_at => created_at.to_i,
    Severity: Major
    Found in app/models/post/api_methods.rb - About 2 hrs to fix

      Function setup has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        setup: function(){
          function parseColor(color){
            if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
            color = color.parseColor();
            return $R(0,2).map(function(i){
      Severity: Minor
      Found in lib/assets/javascripts/prototype/effects.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 setDimensions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        setDimensions: function(height, width) {
          var d = { };
          if (this.options.scaleX) d.width = width.round() + 'px';
          if (this.options.scaleY) d.height = height.round() + 'px';
          if (this.options.scaleFromCenter) {
      Severity: Minor
      Found in lib/assets/javascripts/prototype/effects.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 parseColor has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      String.prototype.parseColor = function() {
        var color = '#';
        if (this.slice(0,4) == 'rgb(') {
          var cols = this.slice(4,this.length-1).split(',');
          var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
      Severity: Minor
      Found in lib/assets/javascripts/prototype/effects.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 search has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def search
          @comments = Comment.order(:id => :desc)
      
          if params[:query]
            keywords = []
      Severity: Minor
      Found in app/controllers/comment_controller.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

      Function Serializers has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Form.Element.Serializers = (function() {
        function input(element, value) {
          switch (element.type.toLowerCase()) {
            case 'checkbox':
            case 'radio':
      Severity: Major
      Found in lib/assets/javascripts/prototype/prototype.js - About 2 hrs to fix

        Method set_avatar has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def set_avatar(params)
              post = Post.find(params[:post_id])
              unless post.can_be_seen_by?(self)
                errors.add(:access, "denied")
                return false
        Severity: Major
        Found in app/models/user.rb - About 2 hrs to fix

          Method http_get_streaming has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Severity: Major
          Found in lib/danbooru.rb - About 2 hrs to fix

            Function Class has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var Class = (function() {
            
              var IS_DONTENUM_BUGGY = (function(){
                for (var p in { toString: 1 }) {
                  if (p === 'toString') return false;
            Severity: Major
            Found in lib/assets/javascripts/prototype/prototype.js - About 2 hrs to fix

              Function extend has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Element.extend = (function() {
              
                function checkDeficiency(tagName) {
                  if (typeof window.Element != 'undefined') {
                    var proto = window.Element.prototype;
              Severity: Major
              Found in lib/assets/javascripts/prototype/prototype.js - About 2 hrs to fix

                Slider has 22 functions (exceeds 20 allowed). Consider refactoring.
                Open

                Control.Slider = Class.create({
                  initialize: function(handle, track, options) {
                    var slider = this;
                
                    if (Object.isArray(handle)) {
                Severity: Minor
                Found in lib/assets/javascripts/prototype/slider.js - About 2 hrs to fix

                  Function filter has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Sizzle.filter = function(expr, set, inplace, not){
                      var old = expr, result = [], curLoop = set, match, anyFound,
                          isXMLFilter = set && set[0] && isXML(set[0]);
                  
                      while ( expr && set.length ) {
                  Severity: Major
                  Found in lib/assets/javascripts/prototype/prototype.js - About 2 hrs to fix

                    Method index has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def index
                        @pools = Pool.all
                        options = {
                          :per_page => 20,
                          :page => page_number
                    Severity: Major
                    Found in app/controllers/pool_controller.rb - About 2 hrs to fix

                      Function finishDrag has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        finishDrag: function(event, success) {
                          this.dragging = false;
                      
                          if(this.options.quiet){
                            Position.prepare();
                      Severity: Minor
                      Found in lib/assets/javascripts/prototype/dragdrop.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 onEmptyHover has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        onEmptyHover: function(element, dropon, overlap) {
                          var oldParentNode = element.parentNode;
                          var droponOptions = Sortable.options(dropon);
                      
                          if(!Element.isParent(dropon, element)) {
                      Severity: Minor
                      Found in lib/assets/javascripts/prototype/dragdrop.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 undo has 56 lines of code (exceeds 25 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: Major
                      Found in app/models/history.rb - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language