jshoe/coursequestionbank

View on GitHub

Showing 16 of 64 total issues

Method update has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    problem = Problem.find(params[:id])

    if !params[:privacy].nil?
      authorize! :set_privacy, problem
Severity: Minor
Found in app/controllers/problems_controller.rb - About 6 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 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update
    problem = Problem.find(params[:id])

    if !params[:privacy].nil?
      authorize! :set_privacy, problem
Severity: Major
Found in app/controllers/problems_controller.rb - About 2 hrs to fix

    Method create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        parent_uid = params[:parent_uid]
        if parent_uid
          previous_version = Problem.find_by_uid(params[:parent_uid])
          if !previous_version
    Severity: Minor
    Found in app/controllers/problems_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

    Method create has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create
        parent_uid = params[:parent_uid]
        if parent_uid
          previous_version = Problem.find_by_uid(params[:parent_uid])
          if !previous_version
    Severity: Minor
    Found in app/controllers/problems_controller.rb - About 1 hr to fix

      Method filter has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.filter(user, filters, bump_problem)
          problems = Problem.search do
            any_of do
              with(:instructor_id, user.id)
              with(:is_public, true)
      Severity: Minor
      Found in app/models/problem.rb - About 1 hr to fix

        Method set_filters has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def set_filters
            session[:filters] = session[:filters].merge params.slice(:search, :tags, :sort_by)
        
            if session[:filters][:tags].is_a? String
              session[:filters][:tags] = self.class.parse_list session[:filters][:tags]
        Severity: Minor
        Found in app/controllers/problems_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 filter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.filter(user, filters, bump_problem)
            problems = Problem.search do
              any_of do
                with(:instructor_id, user.id)
                with(:is_public, true)
        Severity: Minor
        Found in app/models/problem.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 store_as_json has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.store_as_json(user, file)
            filename = file.path
            Quiz.nuke_from_orbit
            Quiz.instance_eval "#{IO.read(filename)}"
            collections = []
        Severity: Minor
        Found in app/models/ruql_reader.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 setup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          setup: function() {
            $('.bloom-buttons').each(function() {
              var container = $(this);
              container.find('form').submit(function() {
                $.ajax({
        Severity: Minor
        Found in app/assets/javascripts/problems.js - About 1 hr to fix

          Method update_whitelist has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def update_whitelist
              authorize! :manage, Whitelist
              username = params[:username] ? params[:username].strip : nil
              provider = params[:provider]
              privilege = params[:privilege]
          Severity: Minor
          Found in app/controllers/instructors_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 update_whitelist has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def update_whitelist
              authorize! :manage, Whitelist
              username = params[:username] ? params[:username].strip : nil
              provider = params[:provider]
              privilege = params[:privilege]
          Severity: Minor
          Found in app/controllers/instructors_controller.rb - About 1 hr to fix

            Method set_filters has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def set_filters
                session[:filters] = session[:filters].merge params.slice(:search, :tags, :sort_by)
            
                if session[:filters][:tags].is_a? String
                  session[:filters][:tags] = self.class.parse_list session[:filters][:tags]
            Severity: Minor
            Found in app/controllers/problems_controller.rb - About 1 hr to fix

              Method render_from_json has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.render_from_json(json_code, uid, prev_uid)
                  result = ""
                  return "" if json_code == nil || json_code.length <= 2
                  json_hash = JSON.parse(json_code)
                  answers = json_hash["answers"]
              Severity: Minor
              Found in lib/ruql_renderer.rb - About 55 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 update_multiple_tags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def update_multiple_tags
                  new_tags = self.class.parse_list params[:tag_names]
                  selected = params[:checked_problems] ? params[:checked_problems].keys : []
                  if new_tags == []
                    flash[:error] = "You need to enter a tag."
              Severity: Minor
              Found in app/controllers/problems_controller.rb - About 45 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 export has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def export(format)
                  if problems.empty? 
                    return nil
                  else 
                    if format == 'ruql'
              Severity: Minor
              Found in app/models/collection.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 html5 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def html5
                  if rendered_text
                    return rendered_text
                  end
              
              
              Severity: Minor
              Found in app/models/problem.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