skandragon/thing

View on GitHub

Showing 175 of 175 total issues

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

      def render_ics(options, filename, cache_filename = nil)
        @options = options
        @options = {} if options.nil?
        @options.reverse_merge!({
          calendar_name: "Pennsic #{Pennsic.year} Master Schedule",
    Severity: Minor
    Found in app/lib/calendar_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

    Class Instructable has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Instructable < ApplicationRecord
      belongs_to :user
      has_many :instances, -> { order('start_time, location') }, dependent: :destroy
      has_many :changelogs, as: :target
      accepts_nested_attributes_for :instances, allow_destroy: true
    Severity: Minor
    Found in app/models/instructable.rb - About 3 hrs to fix

      File changelog.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Changelog < ApplicationRecord
        belongs_to :user
        belongs_to :target, polymorphic: true
      
        default_scope { where(year: 2032) }
      Severity: Minor
      Found in app/models/changelog.rb - About 3 hrs to fix

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

          def render_topic_list(pdf, instructables)
            pdf.move_down 8 unless pdf.cursor == pdf.bounds.top
            pdf.font_size 14
            pdf.text instructables.first.topic
            pdf.font_size PDF_FONT_SIZE
        Severity: Minor
        Found in app/lib/calendar_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_pdf has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

          def render_pdf(filename, cache_filename = nil, user = nil)
            pdf = Prawn::Document.new(page_size: 'LETTER', page_layout: :landscape,
              :compress => true, :optimize_objects => true,
              :info => {
                :Title => "Pennsic University #{Pennsic.year} Timesheet for #{@date}, track #{@track}",
        Severity: Minor
        Found in app/controllers/coordinator/locations_controller.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 index has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            @allowed_tracks = current_user.allowed_tracks
        
            @approved = get_param(:approved)
            @date = get_param(:date)
        Severity: Minor
        Found in app/controllers/coordinator/instructables_controller.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 index has 86 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def index
            render_options = {}
        
            respond_to do |format|
              uncached = params[:uncached_for_tests].present?
        Severity: Major
        Found in app/controllers/calendars_controller.rb - About 3 hrs to fix

          Method render_pdf has 85 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def render_pdf(filename, cache_filename = nil, user = nil)
              pdf = Prawn::Document.new(page_size: 'LETTER', page_layout: :landscape,
                :compress => true, :optimize_objects => true,
                :info => {
                  :Title => "Pennsic University #{Pennsic.year} Timesheet for #{@date}, track #{@track}",
          Severity: Major
          Found in app/controllers/coordinator/locations_controller.rb - About 3 hrs to fix

            Method show has 83 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def show
                # TODO: need to handle format here, and return an empty schedule for ICS requests
                # where the user does exist, 404 where it does not, and redirect for html requests.
            
                raise ActiveRecord::RecordNotFound.new('Not Found') unless @user
            Severity: Major
            Found in app/controllers/users/schedules_controller.rb - About 3 hrs to fix

              Method index has 79 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def index
                  @allowed_tracks = current_user.allowed_tracks
              
                  @approved = get_param(:approved)
                  @date = get_param(:date)
              Severity: Major
              Found in app/controllers/coordinator/instructables_controller.rb - About 3 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                      if change[:instances].present?
                        interesting = change[:instances].select { |i|
                          (i.action == 'update'
                            ((i.current and i.current.start_time and i.current.start_time >= start_date and i.current.start_time <= end_date) or
                             (i.original and i.original.start_time and i.original.start_time >= start_date and i.original.start_time <= end_date))) or
                Severity: Critical
                Found in app/models/changelog.rb - About 3 hrs to fix

                  Function formatDate has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          formatDate:       function (date, format, language, type) {
                              if (date == null) {
                                  return '';
                              }
                              var val;
                  Severity: Major
                  Found in app/assets/javascripts/datetimepicker/bootstrap-datetimepicker.js - About 2 hrs to fix

                    Function updateNavArrows has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            updateNavArrows: function () {
                                var d = new Date(this.viewDate),
                                    year = d.getUTCFullYear(),
                                    month = d.getUTCMonth(),
                                    day = d.getUTCDate(),
                    Severity: Major
                    Found in app/assets/javascripts/datetimepicker/bootstrap-datetimepicker.js - About 2 hrs to fix

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

                                  for (var i = 0, el, ev; i < this._events.length; i++) {
                                      el = this._events[i][0];
                                      ev = this._events[i][1];
                                      el.off(ev);
                                  }
                      app/assets/javascripts/datetimepicker/bootstrap-datetimepicker.js on lines 260..264

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

                      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

                                  for (var i = 0, el, ev; i < this._events.length; i++) {
                                      el = this._events[i][0];
                                      ev = this._events[i][1];
                                      el.on(ev);
                                  }
                      app/assets/javascripts/datetimepicker/bootstrap-datetimepicker.js on lines 268..272

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

                      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

                      Class Changelog has 23 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Changelog < ApplicationRecord
                        belongs_to :user
                        belongs_to :target, polymorphic: true
                      
                        default_scope { where(year: 2032) }
                      Severity: Minor
                      Found in app/models/changelog.rb - About 2 hrs to fix

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

                              format.xlsx {
                                if @user.schedule.nil? or @user.schedule.instructables.count == 0
                                  raise ActiveRecord::RecordNotFound.new('Not Found')
                                end
                        
                        
                        Severity: Major
                        Found in app/controllers/users/schedules_controller.rb and 1 other location - About 2 hrs to fix
                        app/controllers/users/schedules_controller.rb on lines 76..92

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

                        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

                              format.csv {
                                if @user.schedule.nil? or @user.schedule.instructables.count == 0
                                  raise ActiveRecord::RecordNotFound.new('Not Found')
                                end
                        
                        
                        Severity: Major
                        Found in app/controllers/users/schedules_controller.rb and 1 other location - About 2 hrs to fix
                        app/controllers/users/schedules_controller.rb on lines 95..111

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

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

                          def self.interesting_change(change, start_date, end_date)
                            action = change[:action]
                        
                            ret = []
                        
                        
                        Severity: Minor
                        Found in app/models/changelog.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

                        Severity
                        Category
                        Status
                        Source
                        Language