yippie-io/iUPB

View on GitHub

Showing 49 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

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

                            left: (o.left == 'auto' ? tp.x-ep.x + (target.offsetWidth >> 1) : o.left+mid) + 'px',
                  Severity: Major
                  Found in app/assets/javascripts/libs/spin.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/libs/spin.js on lines 163..163

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

                  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

                            top: (o.top == 'auto' ? tp.y-ep.y + (target.offsetHeight >> 1) : o.top+mid)  + 'px'
                  Severity: Major
                  Found in app/assets/javascripts/libs/spin.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/libs/spin.js on lines 162..162

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

                  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

                              posX = isIPad ? w.scrollX - startX : w.scrollX + Math.round((w.innerWidth - balloon.offsetWidth) / 2) - startX;
                  Severity: Minor
                  Found in public/scripts/add2home.js and 1 other location - About 50 mins to fix
                  public/scripts/add2home.js on lines 252..252

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

                  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

                              posX = isIPad ? w.scrollX - startX : w.scrollX + Math.round((w.innerWidth - balloon.offsetWidth)/2) - startX;
                  Severity: Minor
                  Found in public/scripts/add2home.js and 1 other location - About 50 mins to fix
                  public/scripts/add2home.js on lines 316..316

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

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

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

                    def facebook
                      # You need to implement the method below in your model
                      @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
                  
                      if @user.persisted?
                  Severity: Minor
                  Found in app/controllers/users/omniauth_callbacks_controller.rb and 1 other location - About 40 mins to fix
                  app/controllers/users/omniauth_callbacks_controller.rb on lines 15..23

                  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

                    def google_oauth2
                        @user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)
                  
                        if @user.persisted?
                          flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google"
                  Severity: Minor
                  Found in app/controllers/users/omniauth_callbacks_controller.rb and 1 other location - About 40 mins to fix
                  app/controllers/users/omniauth_callbacks_controller.rb on lines 2..11

                  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

                  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

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

                        , settings = { container: window
                                     , currentPage: 1
                                     , distance: 100
                                     , pagination: '.pagination'
                                     , params: {}
                    Severity: Minor
                    Found in app/assets/javascripts/libs/jquery.pageless.js and 1 other location - About 35 mins to fix
                    app/assets/javascripts/libs/jquery.pageless.js on lines 81..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 47.

                    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