mluukkai/labtool

View on GitHub

Showing 20 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

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

                    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

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

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

                              def unique_assignment
                                return true if Course.active.review_round == 1
                            
                                # there exists some cases where an unique assignment is not possible,.. the following is for those
                                @trials ||= 0
                            Severity: Minor
                            Found in app/controllers/peer_reviews_controller.rb - About 35 mins 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 format_nice has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def format_nice (coll)
                                if coll.is_a? Hash
                                  coll.each do |key, value|
                                    coll[key] = format_nice(value)
                                  end
                            Severity: Minor
                            Found in app/controllers/checklists_controller.rb - About 25 mins 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