yippie-io/iUPB

View on GitHub

Showing 39 of 49 total issues

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

  def index
    restaurant = params[:restaurant] || "Mensa"
    @restaurant = Restaurant.where(name: restaurant).first
    @restaurants = Restaurant.all(sort: [[ :name, :desc ]])
  
Severity: Minor
Found in app/controllers/restaurants_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 call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def call(env)
      if env['REQUEST_METHOD'] == 'GET'
        request = Rack::Request.new(env)
        encoding = Rack::Utils.select_best_encoding(
          %w(gzip identity), request.accept_encoding)
Severity: Minor
Found in lib/middleware/compressed_static_assets.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 spin has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    spin: function(target) {
      this.stop();
      var self = this;
      var o = self.opts;
      var el = self.el = css(createEl(0, {className: o.className}), {position: 'relative', zIndex: o.zIndex});
Severity: Minor
Found in app/assets/javascripts/libs/spin.js - About 1 hr to fix

    Function autogrow has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    $.fn.autogrow = function(options) {
    
        this.filter('textarea').each(function() {
    
            var $this       = $(this),
    Severity: Minor
    Found in app/assets/javascripts/libs/autogrow.js - About 1 hr to fix

      Function getJSON has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function getJSON(url, data, fn) {
          if (jQuery.isFunction(data)) {
            fn = data;
            data = null;
          }
      Severity: Minor
      Found in app/assets/javascripts/libs/jquery.offline.js - About 1 hr to fix

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

          def index
            restaurant = params[:restaurant] || "Mensa"
            @restaurant = Restaurant.where(name: restaurant).first
            @restaurants = Restaurant.all(sort: [[ :name, :desc ]])
          
        Severity: Minor
        Found in app/controllers/restaurants_controller.rb - About 1 hr to fix

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

                Spinner.prototype.lines = function(el, o) {
                  var r = o.length+o.width;
                  var s = 2*r;
          
                  function grp() {
          Severity: Minor
          Found in app/assets/javascripts/libs/spin.js - About 1 hr to fix

            Function watch has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              var watch = function() {
                // listener was stopped or we've run out of pages
                if (settings.totalPages <= settings.currentPage) {
                  stopListener();
                  // if there is a afterStopListener callback we call it
            Severity: Minor
            Found in app/assets/javascripts/libs/jquery.pageless.js - About 1 hr to fix

              Function Datepicker has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  var Datepicker = function(element, options){
                      this.element = $(element);
                      this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
                      this.picker = $(DPGlobal.template)
                                          .appendTo('body')
              Severity: Minor
              Found in app/assets/javascripts/libs/bootstrap-datepicker.js - About 1 hr to fix

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

                    lines: function(el, o) {
                      var i = 0;
                      var seg;
                
                      function fill(color, shadow) {
                Severity: Minor
                Found in app/assets/javascripts/libs/spin.js - About 1 hr to fix

                  Method update_database has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.update_database
                      Restaurant.all.each do |restaurant|
                        restaurant.menus.where(:date.lt => Date.today.to_time.midnight.utc).destroy_all
                      end
                      self.get_menu_data(ENV["STWPB_CSV_URL"]).each do |restaurant, menus|
                  Severity: Minor
                  Found in lib/restaurant_helper.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 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def export
                      events = current_user.events.where(start_time: Time.now..(Time.now + 6.months))
                      respond_to do |format|
                        format.ics do
                          @cal = RiCal.Calendar do |cal|
                  Severity: Minor
                  Found in app/controllers/timetable_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

                  Consider simplifying this complex logical expression.
                  Open

                          if ( !overrideChecks && (!isSafari || !isExpired || isSessionActive || isStandalone || !isReturningVisitor) ) return;
                  Severity: Major
                  Found in public/scripts/add2home.js - About 40 mins to fix

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

                      def recurring_end_greater_than_start_time
                          if recurring
                            if recurring_end
                              errors.add(:recurring_end, "can't be set before start time") if recurring_end < start_time.to_date
                            else
                    Severity: Minor
                    Found in app/models/event.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 parsed_side_dishes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def parsed_side_dishes(locale = nil)
                        result = {}
                          if self[:side_dishes].respond_to?(:each)
                            self[:side_dishes].each do |key, val|
                            result[key] = JSON.parse(val) if val
                    Severity: Minor
                    Found in app/models/menu.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 update_next_class_information! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def update_next_class_information!
                        min_interval = 100.days
                        self.course_data.each do |data|
                          date = data["date"]
                          time_from_key = "time_from"
                    Severity: Minor
                    Found in app/models/course.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 extract_youtube_videos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def extract_youtube_videos (html_string)
                        urls = URI.extract html_string
                        urls_converted = urls.uniq.map do |url| 
                          if url.blank? 
                            nil 
                    Severity: Minor
                    Found in app/controllers/ads_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

                    Method _name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def _name
                        if self.course and !self.custom
                          return self.course.title if self.course.course_type === "course"
                          return self.course.group_title if self.course.course_type === "group"
                        end
                    Severity: Minor
                    Found in app/models/event.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

                    Method update_recurring has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def update_recurring # untested. might be an infinite loop. TODO
                        if self.recurring or self.parent_event
                          (self.recurring ? self : self.parent_event).children_events.each do |e|
                            e.update_attributes(name: self.name, start_time: self.start_time, end_time: self.end_time, location: self.location)
                          end
                    Severity: Minor
                    Found in app/models/event.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