concord-consortium/rigse

View on GitHub

Showing 2,136 of 2,138 total issues

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

  register: function(win) {
    if (this.getWindow(win.id)) return;

    this.handlePosition(win);
    this.stack.add(win);
Severity: Major
Found in rails/app/assets/javascripts/livepipe/window.js and 2 other locations - About 1 hr to fix
rails/app/assets/javascripts/prototype-ui/prototype-ui.js on lines 4619..4625
rails/public/javascripts/light_box.js on lines 4619..4625

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

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

Object.extend(Number.prototype, {
  // Snap a number to a grid
  snap: function(round) {
    return parseInt(round == 1 ? this : (this / round).floor() * round);
  }
Severity: Major
Found in rails/app/assets/javascripts/livepipe/window.js and 2 other locations - About 1 hr to fix
rails/app/assets/javascripts/prototype-ui/prototype-ui.js on lines 123..128
rails/public/javascripts/light_box.js on lines 123..128

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

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

    DEFAULT_DATA[:teacher_clazzes].each do |teacher_clazz, teacher_clazz_info|
      map_teacher = @default_teachers.find{|t| t.user.login == teacher_clazz_info[:teacher]}
      if map_teacher
        clazz_names = teacher_clazz_info[:clazz_names].split(",").map{|c| c.strip }
        clazz_names.each do |clazz_name|
Severity: Major
Found in rails/lib/mock_data/create_default_data.rb and 1 other location - About 1 hr to fix
rails/lib/mock_data/create_default_data.rb on lines 482..489

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

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

    DEFAULT_DATA[:student_clazzes].each do |student_clazz, student_clazz_info|
      map_student = @default_students.find{|s| s.user.login == student_clazz_info[:student]}
      if map_student
        clazz_names = student_clazz_info[:clazz_names].split(",").map{|c| c.strip }
        clazz_names.each do |clazz_name|
Severity: Major
Found in rails/lib/mock_data/create_default_data.rb and 1 other location - About 1 hr to fix
rails/lib/mock_data/create_default_data.rb on lines 468..475

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

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 when has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    when: function( subordinate /* , ..., subordinateN */ ) {
        var i = 0,
            resolveValues = core_slice.call( arguments ),
            length = resolveValues.length,

Severity: Minor
Found in rails/app/assets/javascripts/jquery/jquery.js - About 1 hr to fix

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

      function update(element, content) {
        element = $(element);
    
        var descendants = element.getElementsByTagName('*'),
          i = descendants.length;
    Severity: Minor
    Found in rails/app/assets/javascripts/prototype.js - About 1 hr to fix

      Function serializeElements has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        serializeElements: function(elements, options) {
          if (typeof options != 'object') options = { hash: !!options };
          else if (Object.isUndefined(options.hash)) options.hash = true;
          var key, value, submitted = false, submit = options.submit, accumulator, initial;
      
      
      Severity: Minor
      Found in rails/app/assets/javascripts/prototype.js - About 1 hr to fix

        Function plotBarsShadows has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            plotBarsShadows: function(series, barWidth, offset){
                var data = series.data;
                if(data.length < 1) return;
                
                var xa = series.xaxis,
        Severity: Minor
        Found in rails/app/assets/javascripts/flotr/flotr_out.js - About 1 hr to fix

          Function plotBarsShadows has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              plotBarsShadows: function(series, barWidth, offset){
                  var data = series.data;
                  if(data.length < 1) return;
                  
                  var xa = series.xaxis,
          Severity: Minor
          Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr to fix

            Function result_select has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                Chosen.prototype.result_select = function(evt) {
                  var high, item;
                  if (this.result_highlight) {
                    high = this.result_highlight;
                    this.result_clear_highlight();
            Severity: Minor
            Found in rails/app/assets/javascripts/chosen.proto.js - About 1 hr to fix

              Function start has 36 lines of code (exceeds 25 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 rails/app/assets/javascripts/effects.js - About 1 hr to fix

                Function finishDrag has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  finishDrag: function(event, success) {
                    this.dragging = false;
                
                    if(this.options.quiet){
                      Position.prepare();
                Severity: Minor
                Found in rails/app/assets/javascripts/dragdrop.js - About 1 hr to fix

                  Method import_model_library has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def import_model_library
                      authorize Interactive
                      if request.post?
                        respond_to do |format|
                          begin
                  Severity: Minor
                  Found in rails/app/controllers/interactives_controller.rb - About 1 hr to fix

                    Method add_favorite has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def add_favorite
                    
                        if !current_user || current_user.anonymous?
                          render json: {:message => "Cannot add favorite for non-logged in user."},
                                        :status => 400
                    Severity: Minor
                    Found in rails/app/controllers/api/v1/materials_controller.rb - About 1 hr to fix

                      Method initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def initialize(params, current_visitor, options={})
                          @es_learners = []
                          @learners = []
                          @runnable_names = []
                          @last_hit_sort_value = nil
                      Severity: Minor
                      Found in rails/app/models/report/learner/selector.rb - About 1 hr to fix

                        Function teacherProjectViewsList has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          teacherProjectViewsList () {
                            const { showLoadingMessage, teacherProjectViews, loaded } = this.state;
                            if (!loaded) {
                              if (showLoadingMessage === false) {
                                return null;

                          Function calculateSpacing has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              calculateSpacing: function(){
                                  var a = this.axes,
                                        options = this.options,
                                        series = this.series,
                                        margin = options.grid.labelMargin,
                          Severity: Minor
                          Found in rails/app/assets/javascripts/flotr/flotr_out.js - About 1 hr 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 calculateSpacing has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              calculateSpacing: function(){
                                  var a = this.axes,
                                        options = this.options,
                                        series = this.series,
                                        margin = options.grid.labelMargin,
                          Severity: Minor
                          Found in rails/app/assets/javascripts/flotr/flotr.js - About 1 hr 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 for_teacher_only? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def for_teacher_only?(thing)
                              if (thing.respond_to?("teacher_only?") && thing.teacher_only?)
                                return true;
                              end
                              if thing.respond_to? :parent
                          Severity: Minor
                          Found in rails/app/helpers/application_helper.rb - About 1 hr 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 accordion_for has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def accordion_for(model, title, dom_prefix='', options={})
                              show_hide_text = options[:show_hide_text]
                              capture_haml do
                                haml_tag :div, :id => dom_id_for(model, dom_prefix), :class => 'accordion_container' do
                                  haml_tag :div, :class => 'accordion_name' do
                          Severity: Minor
                          Found in rails/app/helpers/application_helper.rb - About 1 hr 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