cloudspokes/cs-website-cms

View on GitHub

Showing 93 of 93 total issues

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

$(function() {

  // Add new prize sets
  $('.add-new-prize-set').live('click', function(e) {
    $('#prize-set tbody').append('\
Severity: Major
Found in app/assets/javascripts/admin/challenges.js and 1 other location - About 1 day to fix
app/assets/javascripts/challenges.js on lines 51..93

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

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

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

$(function() {

  // Add new prize sets
  $('.add-new-prize-set').live('click', function(e) {
    $('#prize-set tbody').append('\
Severity: Major
Found in app/assets/javascripts/challenges.js and 1 other location - About 1 day to fix
app/assets/javascripts/admin/challenges.js on lines 78..120

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

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

function validateForm() {

  var errors = [];
  var startDate = new Date($('#date-range-hidden-start').val());
  var endDate = new Date($('#date-range-hidden-end').val());
Severity: Major
Found in app/assets/javascripts/challenges.js and 1 other location - About 1 day to fix
app/assets/javascripts/admin/challenges.js on lines 49..76

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

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

function validateForm() {

  var errors = [];
  var startDate = new Date($('#date-range-hidden-start').val());
  var endDate = new Date($('#date-range-hidden-end').val());
Severity: Major
Found in app/assets/javascripts/admin/challenges.js and 1 other location - About 1 day to fix
app/assets/javascripts/challenges.js on lines 22..49

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

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

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

class Challenge < ApiModel
  include Redis::ChallengeSearchable

  attr_accessor :id, :challenge_id, :challenge_type, :attributes,
    :prize_type, :total_prize_money, :top_prize,
Severity: Minor
Found in app/models/challenge.rb - About 6 hrs to fix

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

    class ChallengesController < ApplicationController
    
      before_filter :authenticate_user!, :only => [:preview, :preview_survey, :review, :register, 
        :watch, :agree_tos, :submission, :submissions, :submission_view_only, :comment, 
        :submit, :submit_details, :participant_submissions, :results_scorecard, :appeals]
    Severity: Minor
    Found in app/controllers/challenges_controller.rb - About 5 hrs to fix

      File challenges_controller.rb has 372 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'will_paginate/array'
      require 'digest/sha1'
      
      class ChallengesController < ApplicationController
      
      
      Severity: Minor
      Found in app/controllers/challenges_controller.rb - About 4 hrs to fix

        File bootstrap-typeahead.js has 318 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        
        !
        function ($) {
        
          'use strict';
        Severity: Minor
        Found in app/assets/javascripts/bootstrap-typeahead.js - About 3 hrs to fix

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

          class ApiModel
            include ActiveModel::Model
          
            cattr_accessor :access_token  
          
          
          Severity: Minor
          Found in app/models/api_model.rb - About 3 hrs to fix

            Method getJsConnectString has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

                def JsConnect.getJsConnectString(user, request = {}, client_id = "", secret = "", secure = true)
                  error = nil
                  
                  timestamp = request["timestamp"].to_i
                  current_timestamp = JsConnect.timestamp
            Severity: Minor
            Found in lib/js_connect.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

            Class Challenge has 26 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Admin::Challenge
              include ActiveModel::Model
            
              STATUSES = [['Draft', 'Draft'] ,['Open for Submissions', 'Open for Submissions'] ,['Hidden', 'Hidden']]
            
            
            Severity: Minor
            Found in app/models/admin/challenge.rb - About 3 hrs to fix

              Method initialize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                def initialize(params={})
                  # there has GOT to be some better way to clean this up ...
                  params['categories'] = params.delete('challenge_categories__r') if params['challenge_categories__r']
                  params['platforms'] = params.delete('challenge_platforms__r') if params['challenge_platforms__r']
                  params['technologies'] = params.delete('challenge_technologies__r') if params['challenge_technologies__r']
              Severity: Minor
              Found in app/models/challenge.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 has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                def update
              
                  # scrub out this crap when nothing submitted in ckeditor -- <p>&Acirc;&#32;</p>\r\n (see http://dev.ckeditor.com/ticket/9732)
                  params[:admin_challenge][:description] = nil if params[:admin_challenge][:description].include?('&Acirc;&#32;')
                  params[:admin_challenge][:requirements] = nil if params[:admin_challenge][:requirements].include?('&Acirc;&#32;')
              Severity: Minor
              Found in app/controllers/admin/challenges_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 startWheel has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function startWheel() {
                      $('.spinner-wrap .spin-btn').addClass("disabled");        
              
                      var group = $(".spinner .group");
                      var time = 0;
              Severity: Major
              Found in app/assets/javascripts/mashathon/script.js - About 2 hrs to fix

                File script.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                /*
                 * SuperAwesome Cloud API Mashathon Virtual Spinner JavaScript file
                 */
                
                $(document).ready(function(){
                Severity: Minor
                Found in app/assets/javascripts/mashathon/script.js - About 2 hrs to fix

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

                  function prevTab(elem) {
                    $(elem + ' li.active')
                      .prev()
                      .find('a[data-toggle="tab"]')
                      .click();
                  Severity: Major
                  Found in app/assets/javascripts/challenges.js and 3 other locations - About 2 hrs to fix
                  app/assets/javascripts/admin/challenges.js on lines 28..37
                  app/assets/javascripts/admin/challenges.js on lines 39..47
                  app/assets/javascripts/challenges.js on lines 1..10

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

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

                  function nextTab(elem) {
                    $(elem + ' li.active')
                      .next()
                      .find('a[data-toggle="tab"]')
                      .click();
                  Severity: Major
                  Found in app/assets/javascripts/challenges.js and 3 other locations - About 2 hrs to fix
                  app/assets/javascripts/admin/challenges.js on lines 28..37
                  app/assets/javascripts/admin/challenges.js on lines 39..47
                  app/assets/javascripts/challenges.js on lines 12..20

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

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

                  function nextTab(elem) {
                    $(elem + ' li.active')
                      .next()
                      .find('a[data-toggle="tab"]')
                      .click();
                  Severity: Major
                  Found in app/assets/javascripts/admin/challenges.js and 3 other locations - About 2 hrs to fix
                  app/assets/javascripts/admin/challenges.js on lines 39..47
                  app/assets/javascripts/challenges.js on lines 1..10
                  app/assets/javascripts/challenges.js on lines 12..20

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

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

                  function prevTab(elem) {
                    $(elem + ' li.active')
                      .prev()
                      .find('a[data-toggle="tab"]')
                      .click();
                  Severity: Major
                  Found in app/assets/javascripts/admin/challenges.js and 3 other locations - About 2 hrs to fix
                  app/assets/javascripts/admin/challenges.js on lines 28..37
                  app/assets/javascripts/challenges.js on lines 1..10
                  app/assets/javascripts/challenges.js on lines 12..20

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

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

                    def self.advanced_search(options)
                      
                      params = Hashie::Mash.new()    
                  
                      if options[:platforms]
                  Severity: Minor
                  Found in app/models/challenge.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

                  Severity
                  Category
                  Status
                  Source
                  Language