otwcode/otwarchive

View on GitHub

Showing 1,204 of 1,204 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            if ( data.collisionWidth > outerWidth ) {
                // element is initially over the left side of within
                if ( overLeft > 0 && overRight <= 0 ) {
                    newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
                    position.left += overLeft - newOverRight;
Severity: Major
Found in public/javascripts/jquery-ui.js and 1 other location - About 1 day to fix
public/javascripts/jquery-ui.js on lines 1322..1347

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

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

Method autocomplete_lookup has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    def autocomplete_lookup(options = {})
      options.reverse_merge!({search_param: "", autocomplete_prefix: "", sort: "down"})
      search_param = options[:search_param]
      autocomplete_prefix = options[:autocomplete_prefix]
      if REDIS_AUTOCOMPLETE.exists(autocomplete_cache_key(autocomplete_prefix, search_param))
Severity: Minor
Found in lib/autocomplete_source.rb - About 1 day 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 ao3modal has 268 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    window.ao3modal = (function($) {

        var _loading = false,
            _bgDiv = $('<div>', {'id': 'modal-bg'}).addClass('modal-closer'),
            _loadingDiv = $('<div>').addClass('loading'),
Severity: Major
Found in public/javascripts/ao3modal.js - About 1 day to fix

    Function ajax has 237 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        ajax: function( url, options ) {
    
            // If url is an object, simulate pre-1.5 signature
            if ( typeof url === "object" ) {
                options = url;
    Severity: Major
    Found in public/javascripts/jquery.js - About 1 day to fix

      File comments_controller.rb has 560 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class CommentsController < ApplicationController
        skip_before_action :store_location, except: [:show, :index, :new]
        before_action :load_commentable,
                      only: [:index, :new, :create, :edit, :update, :show_comments,
                             :hide_comments, :add_comment_reply,
      Severity: Major
      Found in app/controllers/comments_controller.rb - About 1 day to fix

        Function setDocument has 232 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        setDocument = Sizzle.setDocument = function( node ) {
            var doc = node ? node.ownerDocument || node : preferredDoc;
        
            // If no document and documentElement is available, return
            if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
        Severity: Major
        Found in public/javascripts/jquery.js - About 1 day to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  return {
                      top: (
                          pageY -                                                                // The absolute mouse position
                          this.offset.click.top -                                                    // Click offset (relative to the element)
                          this.offset.relative.top    -                                            // Only for relative positioned nodes: Relative offset from element to offset parent
          Severity: Major
          Found in public/javascripts/jquery-ui.js and 1 other location - About 1 day to fix
          public/javascripts/jquery-ui.js on lines 6312..6327

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

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

                  return {
                      top: (
                          pageY -                                                                    // The absolute mouse position
                          this.offset.click.top    -                                                // Click offset (relative to the element)
                          this.offset.relative.top -                                                // Only for relative positioned nodes: Relative offset from element to offset parent
          Severity: Major
          Found in public/javascripts/jquery-ui.js and 1 other location - About 1 day to fix
          public/javascripts/jquery-ui.js on lines 12990..13005

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

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

          $.ui.plugin.add("draggable", "zIndex", {
              start: function(event, ui) {
                  var t = $(ui.helper), o = $(this).data("ui-draggable").options;
                  if(t.css("zIndex")) {
                      o._zIndex = t.css("zIndex");
          Severity: Major
          Found in public/javascripts/jquery-ui.js and 1 other location - About 7 hrs to fix
          public/javascripts/jquery-ui.js on lines 6538..6552

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

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

          $.ui.plugin.add("draggable", "opacity", {
              start: function(event, ui) {
                  var t = $(ui.helper), o = $(this).data("ui-draggable").options;
                  if(t.css("opacity")) {
                      o._opacity = t.css("opacity");
          Severity: Major
          Found in public/javascripts/jquery-ui.js and 1 other location - About 7 hrs to fix
          public/javascripts/jquery-ui.js on lines 6727..6741

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

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

                      if(!o.axis || o.axis !== "x") {
                          if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
                              i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
                          } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
                              i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
          Severity: Major
          Found in public/javascripts/jquery-ui.js and 1 other location - About 7 hrs to fix
          public/javascripts/jquery-ui.js on lines 6575..6581

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

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

                      if(!o.axis || o.axis !== "y") {
                          if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
                              i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
                          } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
                              i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
          Severity: Major
          Found in public/javascripts/jquery-ui.js and 1 other location - About 7 hrs to fix
          public/javascripts/jquery-ui.js on lines 6567..6573

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

          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

          File livevalidation_standalone.js has 488 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // LiveValidation 1.3 (standalone version)
          // Copyright (c) 2007-2008 Alec Hill (www.livevalidation.com)
          // LiveValidation is licensed under the terms of the MIT License
          
          /*********************************************** LiveValidation class ***********************************/
          Severity: Minor
          Found in public/javascripts/livevalidation_standalone.js - About 7 hrs to fix

            Function _create has 191 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _create: function() {
                    // Some browsers only repeat keydown events, not keypress events,
                    // so we use the suppressKeyPress flag to determine if we've already
                    // handled the keydown event. #7269
                    // Unfortunately the code for & in keypress is the same as the up arrow,
            Severity: Major
            Found in public/javascripts/jquery-ui.js - About 7 hrs to fix

              Class User has 53 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class User < ApplicationRecord
                audited redacted: [:encrypted_password, :password_salt]
                include WorksOwner
                include PasswordResetsLimitable
                include UserLoggable
              Severity: Major
              Found in app/models/user.rb - About 7 hrs to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            if(!o.axis || o.axis !== "x") {
                                if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
                                    scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
                                } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
                                    scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
                Severity: Major
                Found in public/javascripts/jquery-ui.js and 1 other location - About 7 hrs to fix
                public/javascripts/jquery-ui.js on lines 6593..6599

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

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

                            if(!o.axis || o.axis !== "y") {
                                if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
                                    scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
                                } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
                                    scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
                Severity: Major
                Found in public/javascripts/jquery-ui.js and 1 other location - About 7 hrs to fix
                public/javascripts/jquery-ui.js on lines 6585..6591

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

                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

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

                  def create
                    unless params[:collection_names]
                      flash[:error] = ts("What collections did you want to add?")
                      redirect_to(request.env["HTTP_REFERER"] || root_path) and return
                    end
                Severity: Minor
                Found in app/controllers/collection_items_controller.rb - About 7 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.js has 475 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                // Place your application-specific JavaScript functions and classes here
                // This file is automatically included by javascript_include_tag :defaults
                
                //things to do when the page loads
                $j(document).ready(function() {
                Severity: Minor
                Found in public/javascripts/application.js - About 7 hrs to fix

                  File skin.rb has 473 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'fileutils'
                  
                  class Skin < ApplicationRecord
                    include HtmlCleaner
                    include CssCleaner
                  Severity: Minor
                  Found in app/models/skin.rb - About 7 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language