mluukkai/labtool

View on GitHub

Showing 22 of 22 total issues

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

  def update_values
    @checklist = Checklist.find params[:id]
    @checklist.grade_callback = params[:checklist][:grade_callback]
    @checklist.title = params[:checklist][:title]
    @checklist.save
Severity: Minor
Found in app/controllers/checklists_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

Function activateTable has 164 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function activateTable() {
    var table = $(this);
    var container = table.parents('.topicContainer');
    var topic_id = table.attr('id').replace('topic_','');
    var min_text = table.find('.min');
Severity: Major
Found in app/assets/javascripts/checklist-editor.js - About 6 hrs to fix

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

      def yaml_to_topics(yaml)
        ordering = 1
        topics = YAML.load(yaml).map do |thash|
          thash = parse_ids_from :topic, thash
          if thash.has_key? "id"
    Severity: Minor
    Found in app/controllers/checklists_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

        container.find('.deleteTopic').click(function() {
          var id = container.find('.topic_id').val();
    
          if (id != "new") {
            var deleteInput = $('<input type="hidden" name="deleted_topics[]" />');
    Severity: Major
    Found in app/assets/javascripts/checklist-editor.js and 1 other location - About 4 hrs to fix
    app/assets/javascripts/checklist-editor.js on lines 222..233

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

    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

            row.find('.deleteCheck').click(function() {
              var id = row.find('.link_id').val();
    
              if (id != "new") {
                var deleteInput = $('<input type="hidden" name="deleted_topics_checks[]" />');
    Severity: Major
    Found in app/assets/javascripts/checklist-editor.js and 1 other location - About 4 hrs to fix
    app/assets/javascripts/checklist-editor.js on lines 132..143

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

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

      def update_values
        @checklist = Checklist.find params[:id]
        @checklist.grade_callback = params[:checklist][:grade_callback]
        @checklist.title = params[:checklist][:title]
        @checklist.save
    Severity: Major
    Found in app/controllers/checklists_controller.rb - About 3 hrs to fix

      File checklists_controller.rb has 309 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class ChecklistsController < ApplicationController
      
        def index
          @checklists = Checklist.order :title
        end
      Severity: Minor
      Found in app/controllers/checklists_controller.rb - About 3 hrs to fix

        Function addTopics has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function addTopics(checklist, topicData) {
            $.each(topicData, function(topic_id,topic) {
              var checks = {}
              $.each(topic.checks, function(check_id,check) {
                var element = $("#"+check_id);
        Severity: Major
        Found in app/assets/javascripts/checklists.js - About 2 hrs to fix

          Method topics_to_yaml has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

            def topics_to_yaml (topics)
              StyledYAML.dump format_nice(topics.map{ |topic|
                ret = topic.attributes.reject {|key,value|
                  %w(ordering checklist_id scoretype_id).include? key or value.nil? 
                }
          Severity: Minor
          Found in app/controllers/checklists_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

          Class Registration has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Registration < ActiveRecord::Base
            attr_accessible :repository, :topic, :active, :review1, :review2
          
            belongs_to :course
            belongs_to :user
          Severity: Minor
          Found in app/models/registration.rb - About 2 hrs to fix

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

            class User < ActiveRecord::Base
              attr_accessible :email, :forename, :student_number, :surename, :password, :password_confirmation
            
              has_secure_password
            
            
            Severity: Minor
            Found in app/models/user.rb - About 2 hrs to fix

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

                def yaml_to_topics(yaml)
                  ordering = 1
                  topics = YAML.load(yaml).map do |thash|
                    thash = parse_ids_from :topic, thash
                    if thash.has_key? "id"
              Severity: Major
              Found in app/controllers/checklists_controller.rb - About 2 hrs to fix

                Function autograding has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  $.fn.autograding = function(topicData) {
                    var feedbackContainer = $(this).find('.feedbacks');
                    var scoreContainer  = $(this).find('.scores');
                    var initScores = getScoreInitializer(topicData.scoretypes);
                    var final_grade_callback = topicData.grade_callback;
                Severity: Minor
                Found in app/assets/javascripts/checklists.js - About 1 hr to fix

                  Function autogrow has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      $.fn.autogrow = function(callback)
                      {
                          return this.filter('textarea').each(function()
                          {
                              var self         = this;
                  Severity: Minor
                  Found in app/assets/javascripts/jquery.autogrow-textarea.js - About 1 hr to fix

                    Method toggle_review_participation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def toggle_review_participation round
                        if round==1
                          self.participate_review1 = participate_review1 ? false : true
                        else
                          self.participate_review2 = participate_review2 ? false : true
                    Severity: Minor
                    Found in app/models/registration.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 prepare_based_on has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def prepare_based_on earlier_feedback, params
                        week_feedback = earlier_feedback
                        week_feedback.text += "\n-------------------\n" unless params[:week_feedback][:text].empty?
                        week_feedback.text += params[:week_feedback][:text] unless params[:week_feedback][:text].empty?
                        week_feedback.hidden_text = "" if week_feedback.hidden_text.nil?
                    Severity: Minor
                    Found in app/controllers/week_feedbacks_controller.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

                    Function calc has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function calc() {
                          var min = 0;
                          var max = 0;
                          for(var i=0; i<cells1.length; i++) {
                            var val1 = parseFloat(cells1[i].value,10);
                    Severity: Minor
                    Found in app/assets/javascripts/checklist-editor.js - About 1 hr to fix

                      Function activateRows has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function activateRows() {
                            table.find('tr:not(.activated)').each(function() {
                              var row = $(this);
                              row.addClass("activated");
                              row.find('.nametext').click(function() {
                      Severity: Minor
                      Found in app/assets/javascripts/checklist-editor.js - About 1 hr to fix

                        Method scalar has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def scalar value, anchor, tag, plain, quoted, style
                        Severity: Minor
                        Found in lib/styled_yaml.rb - About 45 mins to fix

                          Method email has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            def email(from, to, body, subject, cc, course="Ohjelmoinnin harjoitustyo")
                          Severity: Minor
                          Found in app/mailers/notification_mailer.rb - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language