otwcode/otwarchive

View on GitHub

Showing 1,207 of 1,207 total issues

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

                case 37: if (event.ctrlKey || event.metaKey) {
                            $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
                        }
                        handled = event.ctrlKey || event.metaKey;
                        // -1 day on ctrl or command +left
Severity: Major
Found in public/javascripts/jquery-ui.js and 1 other location - About 6 hrs to fix
public/javascripts/jquery-ui.js on lines 3633..3644

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

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

Function size has 156 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.effects.effect.size = function( o, done ) {

    // Create element
    var original, baseline, factor,
        el = $( this ),
Severity: Major
Found in public/javascripts/jquery-ui.js - About 6 hrs to fix

    Class StoryParser has 45 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class StoryParser
      require 'timeout'
      require 'nokogiri'
      require 'mechanize'
      require 'open-uri'
    Severity: Minor
    Found in app/models/story_parser.rb - About 6 hrs to fix

      Class ChallengeAssignment has 44 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class ChallengeAssignment < ApplicationRecord
        # We use "-1" to represent all the requested items matching
        ALL = -1
      
        belongs_to :collection
      Severity: Minor
      Found in app/models/challenge_assignment.rb - About 6 hrs to fix

        Class WorksController has 44 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class WorksController < ApplicationController
          # only registered users and NOT admin should be able to create new works
          before_action :load_collection
          before_action :load_owner, only: [:index]
          before_action :users_only, except: [:index, :show, :navigate, :search, :collected, :edit_tags, :update_tags, :drafts, :share]
        Severity: Minor
        Found in app/controllers/works_controller.rb - About 6 hrs to fix

          Function parseDate has 148 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              parseDate: function (format, value, settings) {
                  if (format == null || value == null) {
                      throw "Invalid arguments";
                  }
          
          
          Severity: Major
          Found in public/javascripts/jquery-ui.js - About 5 hrs to fix

            Function position has 147 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            $.fn.position = function( options ) {
                if ( !options || !options.of ) {
                    return _position.apply( this, arguments );
                }
            
            
            Severity: Major
            Found in public/javascripts/jquery-ui.js - About 5 hrs to fix

              Class BookmarkQuery has 43 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class BookmarkQuery < Query
                attr_accessor :bookmarkable_query
              
                def klass
                  'Bookmark'
              Severity: Minor
              Found in app/models/search/bookmark_query.rb - About 5 hrs to fix

                Method after_update has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                Open

                  def after_update
                    users = []
                    admins = []
                
                    if self.saved_change_to_edited_at? || (self.saved_change_to_unreviewed? && !self.unreviewed?)
                Severity: Minor
                Found in app/models/comment.rb - 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

                Method collect_update_multiple_results has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                Open

                  def collect_update_multiple_results
                    TagSet::TAG_TYPES_INITIALIZABLE.each do |tag_type|
                      @approve[tag_type] = []
                      @synonym[tag_type] = []
                      @reject[tag_type] = []
                Severity: Minor
                Found in app/controllers/tag_set_nominations_controller.rb - 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

                Method index has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                Open

                  def index
                    base_options = {
                      page: params[:page] || 1,
                      show_restricted: current_user.present? || logged_in_as_admin?
                    }
                Severity: Minor
                Found in app/controllers/works_controller.rb - 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

                Class Series has 41 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Series < ApplicationRecord
                  include Bookmarkable
                  include Searchable
                  include Creatable
                
                
                Severity: Minor
                Found in app/models/series.rb - About 5 hrs to fix

                  Method setup_for_review has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def setup_for_review
                      set_limit
                      @nom_limit = 30
                      @nominations = HashWithIndifferentAccess.new
                      @nominations_count = HashWithIndifferentAccess.new
                  Severity: Minor
                  Found in app/controllers/tag_set_nominations_controller.rb - 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 _create has 135 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      _create: function() {
                          this.element.closest( "form" )
                              .unbind( "reset" + this.eventNamespace )
                              .bind( "reset" + this.eventNamespace, formResetHandler );
                  
                  
                  Severity: Major
                  Found in public/javascripts/jquery-ui.js - About 5 hrs to fix

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

                                    pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
                    Severity: Major
                    Found in public/javascripts/jquery-ui.js and 1 other location - About 5 hrs to fix
                    public/javascripts/jquery-ui.js on lines 12985..12985

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

                    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

                                    pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
                    Severity: Major
                    Found in public/javascripts/jquery-ui.js and 1 other location - About 5 hrs to fix
                    public/javascripts/jquery-ui.js on lines 12982..12982

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

                    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 sort_link has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def sort_link(title, column=nil, options = {})
                        condition = options[:unless] if options.has_key?(:unless)
                    
                        unless column.nil?
                          current_column = (params[:sort_column] == column.to_s) || params[:sort_column].blank? && options[:sort_default]
                    Severity: Minor
                    Found in app/helpers/application_helper.rb - 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

                    Method wrangle has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def wrangle
                        params[:page] = '1' if params[:page].blank?
                        params[:sort_column] = 'name' if !valid_sort_column(params[:sort_column], 'tag')
                        params[:sort_direction] = 'ASC' if !valid_sort_direction(params[:sort_direction])
                        options = {show: params[:show], page: params[:page], sort_column: params[:sort_column], sort_direction: params[:sort_direction]}
                    Severity: Minor
                    Found in app/controllers/tag_wranglings_controller.rb - 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

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

                        close_toggles.each(function(){
                          $j(this).click(function(e){
                            if ($j(this).attr('href') == '#') {e.preventDefault();}
                            node.hide();
                            close_toggles.each(function(){$j(this).hide();});
                    Severity: Major
                    Found in public/javascripts/application.js and 1 other location - About 5 hrs to fix
                    public/javascripts/application.js on lines 216..223

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

                    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

                        open_toggles.each(function(){
                          $j(this).click(function(e){
                            if ($j(this).attr('href') == '#') {e.preventDefault();}
                            node.show();
                            open_toggles.each(function(){$j(this).hide();});
                    Severity: Major
                    Found in public/javascripts/application.js and 1 other location - About 5 hrs to fix
                    public/javascripts/application.js on lines 225..232

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language