saasbook/ruql

View on GitHub

Showing 25 of 25 total issues

Method render_fill_in has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def render_fill_in(question)
    @b.question :type => 'GS_Short_Answer_Question_Simple', :id => question.object_id.to_s(16) do
      @b.metadata {
        @b.parameters {
          @b.rescale_score question.points
Severity: Minor
Found in lib/ruql/renderers/xml_renderer.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 render_fill_in has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def render_fill_in(q, idx)
    render_question_text(q, idx) do
      if @show_solutions
        answer = q.answers[0]
        if answer.has_explanation?
Severity: Minor
Found in lib/ruql/renderers/html_form_renderer.rb - About 4 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 render_multiple_choice has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def render_multiple_choice(question)
    # the OLX for select-multiple and select-one are frustratingly different in arbitrary ways
    # single choice has <multiplechoiceresponse> element containing a <choicegroup> with <choice>s
    # select-mult has <choiceresponse> element containing a <checkboxgroup> with <choice>s

Severity: Minor
Found in lib/ruql/renderers/edxml_renderer.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

Method render_open_assessment has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def render_open_assessment(question)
    @b.openassessment url_name: question.url_name,
                      submission_start: "#{question.submission_start.to_s}T"\
                                        "#{question.submission_start_time}:00+00:00",
                      submission_due: "#{question.submission_due.to_s}T"\
Severity: Major
Found in lib/ruql/renderers/edxml_renderer.rb - About 2 hrs to fix

    Class Quiz has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Quiz
      @@quizzes = []
      @@options = {}
    
      attr_reader :renderer
    Severity: Minor
    Found in lib/ruql/quiz.rb - About 2 hrs to fix

      Method render_dropdown has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def render_dropdown(question)
          @b.problem do
            if question.raw?
              @b.p { |p| p << question.question_text }
            else
      Severity: Minor
      Found in lib/ruql/renderers/edxml_renderer.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 render_question_text has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def render_question_text(question,index)
          html_args = {
            :id => "question-#{index}",
            :class => ['question', question.class.to_s.downcase, (question.multiple ? 'multiple' : '')]
              .join(' ')
      Severity: Minor
      Found in lib/ruql/renderers/html_form_renderer.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 render_multiple_choice has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def render_multiple_choice(question)
          # the OLX for select-multiple and select-one are frustratingly different in arbitrary ways
          # single choice has <multiplechoiceresponse> element containing a <choicegroup> with <choice>s
          # select-mult has <choiceresponse> element containing a <checkboxgroup> with <choice>s
      
      
      Severity: Minor
      Found in lib/ruql/renderers/edxml_renderer.rb - About 1 hr to fix

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

          def render(question, index, type='')    
            output = ''
            output << "\\begin{question#{type}}{q#{index}}\n"
            output << "  \\scoring{b=#{question.points},m=#{@penalty*question.points}}\n"
            if type == 'mult'
        Severity: Minor
        Found in lib/ruql/renderers/auto_qcm_renderer.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 render_fill_in has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def render_fill_in(question)
            @b.question :type => 'GS_Short_Answer_Question_Simple', :id => question.object_id.to_s(16) do
              @b.metadata {
                @b.parameters {
                  @b.rescale_score question.points
        Severity: Minor
        Found in lib/ruql/renderers/xml_renderer.rb - About 1 hr to fix

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

            def initialize(options={}, yaml={})
              @peer_review = options[:peer_review] || false
              @self_assessment = options[:self_assessment]
              @self_assessment = true if @self_assessment.nil?
          
          
          Severity: Minor
          Found in lib/ruql/open_assessment/open_assessment.rb - About 1 hr to fix

            Method render_answer_for_solutions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def render_answer_for_solutions(answer,raw)
                args = {:class => (answer.correct? ? 'correct' : 'incorrect')}
                @h.li(args) do
                  if raw then @h.p { |p| p << answer.answer_text } else @h.p answer.answer_text  end
                  if answer.has_explanation?
            Severity: Minor
            Found in lib/ruql/renderers/html_form_renderer.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 render_quiz has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def render_quiz
                if @template
                  render_with_template do
                    render_questions
                    @output
            Severity: Minor
            Found in lib/ruql/renderers/html_form_renderer.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 render has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def render(question, index, type='')    
                output = ''
                output << "\\begin{question#{type}}{q#{index}}\n"
                output << "  \\scoring{b=#{question.points},m=#{@penalty*question.points}}\n"
                if type == 'mult'
            Severity: Minor
            Found in lib/ruql/renderers/auto_qcm_renderer.rb - About 1 hr to fix

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

                def render_multiple_choice(q,index)
                  render_question_text(q, index) do
                    answers =
                      if q.class == TrueFalse then q.answers.sort.reverse # True always first
                      elsif q.randomize then q.answers.sort_by { rand }
              Severity: Minor
              Found in lib/ruql/renderers/html_form_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 render_open_assessment has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def render_open_assessment(question)
                  @b.openassessment url_name: question.url_name,
                                    submission_start: "#{question.submission_start.to_s}T"\
                                                      "#{question.submission_start_time}:00+00:00",
                                    submission_due: "#{question.submission_due.to_s}T"\
              Severity: Minor
              Found in lib/ruql/renderers/edxml_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 render_select_multiple has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def render_select_multiple(q,index)
                  render_question_text(q, index) do
                    answers =
                      if q.randomize then q.answers.sort_by { rand }
                  else q.answers
              Severity: Minor
              Found in lib/ruql/renderers/html_form_renderer.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

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

                    @h.ol :class => 'answers' do
                      answers.each do |answer|
                        if @show_solutions
                          render_answer_for_solutions(answer, q.raw?)
                        else
              Severity: Minor
              Found in lib/ruql/renderers/html_form_renderer.rb and 1 other location - About 35 mins to fix
              lib/ruql/renderers/html_form_renderer.rb on lines 99..107

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

              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

                  @h.ol :class => 'answers' do
                    answers.each do |answer|
                      if @show_solutions
                        render_answer_for_solutions(answer, q.raw?)
                      else
              Severity: Minor
              Found in lib/ruql/renderers/html_form_renderer.rb and 1 other location - About 35 mins to fix
              lib/ruql/renderers/html_form_renderer.rb on lines 76..84

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

              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

                    if question.raw?
                      @b.p { |p| p << question.question_text }
                    else
                      question.question_text.lines.map(&:chomp).each do |line|
                        if question.raw? then @b.p { |p| p << line } else @b.p(line) end
              Severity: Minor
              Found in lib/ruql/renderers/edxml_renderer.rb and 1 other location - About 30 mins to fix
              lib/ruql/renderers/edxml_renderer.rb on lines 85..89

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

              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

              Severity
              Category
              Status
              Source
              Language