skandragon/thing

View on GitHub
sched.rb

Summary

Maintainability
F
5 days
Test Coverage

File sched.rb has 730 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rubygems'

require 'prawn'
require 'json'
require 'pp'
Severity: Major
Found in sched.rb - About 1 day to fix

    Method render_topic_list has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def render_topic_list(pdf, instructables)
      previous_topic = ''
    
      instructables.sort { |a, b|
        [a.formatted_topic, a.name.gsub('*', '')] <=> [b.formatted_topic, b.name.gsub('*', '')]
    Severity: Minor
    Found in sched.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 has 107 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def render(pdf, opts)
      debug = false
    
      if debug
        pdf.stroke_axis
    Severity: Major
    Found in sched.rb - About 4 hrs to fix

      Method render_extra has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def render_extra(pdf, opts)
        rowoffset = opts[:rowoffset]
      
        #box = pdf.grid([rowoffset, 0], [pdf.grid.rows - 1, pdf.grid.columns - 1])
        box = pdf.grid([rowoffset, 0], [rowoffset + 0.2, pdf.grid.columns - 1])
      Severity: Major
      Found in sched.rb - About 2 hrs to fix

        Method draw_hour_labels has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def draw_hour_labels(pdf, opts)
          opts[:hour_labels].count.times do |timeindex|
            opts[:location_labels].count.times do |locindex|
              y1 = @header_height + locindex * @row_height
              x1 = @location_label_width + timeindex * @column_width
        Severity: Major
        Found in sched.rb - About 2 hrs to fix

          Method render_notes has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def render_notes(pdf, opts)
            rowoffset = opts[:rowoffset]
            draw_lines = opts[:mode] == :notes
            draw_box = opts[:mode] == :doodles
          
          
          Severity: Minor
          Found in sched.rb - About 1 hr to fix

            Method render_topic_list has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def render_topic_list(pdf, instructables)
              previous_topic = ''
            
              instructables.sort { |a, b|
                [a.formatted_topic, a.name.gsub('*', '')] <=> [b.formatted_topic, b.name.gsub('*', '')]
            Severity: Minor
            Found in sched.rb - About 1 hr to fix

              Method render_extra has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              def render_extra(pdf, opts)
                rowoffset = opts[:rowoffset]
              
                #box = pdf.grid([rowoffset, 0], [pdf.grid.rows - 1, pdf.grid.columns - 1])
                box = pdf.grid([rowoffset, 0], [rowoffset + 0.2, pdf.grid.columns - 1])
              Severity: Minor
              Found in sched.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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def render(pdf, opts)
                debug = false
              
                if debug
                  pdf.stroke_axis
              Severity: Minor
              Found in sched.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 draw_location_labels has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def draw_location_labels(pdf, opts)
                opts[:location_labels].each_with_index do |label, labelindex|
                  y1 = @header_height + labelindex * @row_height
                  x1 = 0
                  y2 = y1 + @row_height - 1
              Severity: Minor
              Found in sched.rb - About 1 hr to fix

                Method draw_hour_labels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                def draw_hour_labels(pdf, opts)
                  opts[:hour_labels].count.times do |timeindex|
                    opts[:location_labels].count.times do |locindex|
                      y1 = @header_height + locindex * @row_height
                      x1 = @location_label_width + timeindex * @column_width
                Severity: Minor
                Found in sched.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 materials_and_handout_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def materials_and_handout_content(instructable)
                  materials = []
                  handout = []
                  handout << "limit: #{instructable.handout_limit}" if instructable.handout_limit
                  materials << "limit: #{instructable.material_limit}" if instructable.material_limit
                Severity: Minor
                Found in sched.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

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

                def materials_and_handout_content(instructable)
                  materials = []
                  handout = []
                  handout << "limit: #{instructable.handout_limit}" if instructable.handout_limit
                  materials << "limit: #{instructable.material_limit}" if instructable.material_limit
                Severity: Major
                Found in sched.rb and 1 other location - About 2 hrs to fix
                app/lib/calendar_renderer.rb on lines 366..381

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

                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

                  if subentries.count > 0
                    need_new_page = true
                    subentries.sort! { |a, b| a[:start_time].to_i <=> b[:start_time].to_i }
                    render_extra(pdf,
                                 entries: subentries,
                Severity: Major
                Found in sched.rb and 1 other location - About 1 hr to fix
                sched.rb on lines 804..817

                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

                  if subentries.count > 0
                    need_new_page = true
                    subentries.sort! { |a, b| a[:start_time].to_i <=> b[:start_time].to_i }
                    render_extra(pdf,
                                 entries: subentries,
                Severity: Major
                Found in sched.rb and 1 other location - About 1 hr to fix
                sched.rb on lines 766..779

                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

                    if extended_left
                      coords = [
                          [box.top_left[0], box.top_left[1]],
                          [box.top_left[0] + 5, (box.top_left[1] + box.bottom_left[1]) / 2],
                          [box.bottom_left[0], box.bottom_left[1]]
                Severity: Minor
                Found in sched.rb and 1 other location - About 55 mins to fix
                sched.rb on lines 469..476

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

                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

                    if extended_right
                      coords = [
                        [box.top_right[0], box.top_right[1]],
                        [box.top_right[0] + 5, (box.top_right[1] + box.bottom_right[1]) / 2],
                        [box.bottom_right[0], box.bottom_right[1]]
                Severity: Minor
                Found in sched.rb and 1 other location - About 55 mins to fix
                sched.rb on lines 478..485

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

                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

                    box_opts = {
                        at: [box.top_left[0] + 2, box.top_left[1] - 2],
                        width: box.width - 4,
                        height: box.height - 4,
                        size: 10,
                Severity: Minor
                Found in sched.rb and 1 other location - About 40 mins to fix
                sched.rb on lines 347..356

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

                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

                    box_opts = {
                        at: [box.top_left[0] + 2, box.top_left[1] - 2],
                        width: box.width - 4,
                        height: box.height - 4,
                        size: 9,
                Severity: Minor
                Found in sched.rb and 1 other location - About 40 mins to fix
                sched.rb on lines 308..317

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

                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

                  if @locs2.size > 0
                    need_new_page = true
                    render(pdf,
                           location_labels: @locs2,
                           hour_labels: @afternoon_hours,
                Severity: Minor
                Found in sched.rb and 1 other location - About 20 mins to fix
                sched.rb on lines 757..763

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

                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

                  if @locs2.size > 0
                    need_new_page = true
                    render(pdf,
                           location_labels: @locs2,
                           hour_labels: @morning_hours,
                Severity: Minor
                Found in sched.rb and 1 other location - About 20 mins to fix
                sched.rb on lines 795..801

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

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

                  box.bounding_box do
                    pdf.fill_color @grey
                    pdf.stroke_color @grey
                    pdf.fill { pdf.rectangle [0, box.height], box.width, box.height }
                    pdf.stroke_bounds
                Severity: Minor
                Found in sched.rb and 2 other locations - About 15 mins to fix
                sched.rb on lines 494..498
                sched.rb on lines 568..572

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

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

                  box.bounding_box do
                    pdf.fill_color @grey
                    pdf.stroke_color @grey
                    pdf.fill { pdf.rectangle [0, box.height], box.width, box.height }
                    pdf.stroke_bounds
                Severity: Minor
                Found in sched.rb and 2 other locations - About 15 mins to fix
                sched.rb on lines 391..395
                sched.rb on lines 494..498

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

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

                  box.bounding_box do
                    pdf.fill_color @grey
                    pdf.stroke_color @grey
                    pdf.fill { pdf.rectangle [0, box.height], box.width, box.height }
                    pdf.stroke_bounds
                Severity: Minor
                Found in sched.rb and 2 other locations - About 15 mins to fix
                sched.rb on lines 391..395
                sched.rb on lines 568..572

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

                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

                There are no issues that match your filters.

                Category
                Status