andela/eventx

View on GitHub

Showing 106 of 106 total issues

File materialize.clockpicker.js has 523 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* jshint ignore:start */
/*!
 * ClockPicker v0.0.7 (http://weareoutman.github.io/clockpicker/)
 * Copyright 2014 Wang Shenwei.
 * Licensed under MIT (https://github.com/weareoutman/clockpicker/blob/gh-pages/LICENSE)
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js - About 1 day to fix

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

  function ClockPicker(element, options) {
    var popover = $(tpl), plate = popover.find('.clockpicker-plate'), holder = popover.find('.picker__holder'), hoursView = popover.find('.clockpicker-hours'), minutesView = popover.find('.clockpicker-minutes'), amPmBlock = popover.find('.clockpicker-am-pm-block'), isInput = element.prop('tagName') === 'INPUT', input = isInput ? element : element.find('input'), label = $('label[for=' + input.attr('id') + ']'), self = this, timer;
    this.id = uniqueId('cp');
    this.element = element;
    this.holder = holder;
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js - About 7 hrs to fix

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

$(document).ready(function () {
  $('#user_event_search_form input').keyup(function () {
    $.get($('#user_event_search_form').attr('action'), $('#user_event_search_form').serialize(), null, 'script');
    return false;
  });
Severity: Major
Found in app/assets/javascripts/user-event-search-form.js and 1 other location - About 6 hrs to fix
app/assets/javascripts/bookings_search_form.js on lines 1..13

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

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

$(document).ready(function () {
  $('#bookings_search_form input').keyup(function () {
    $.get($('#bookings_search_form').attr('action'), $('#bookings_search_form').serialize(), null, 'script');
    return false;
  });
Severity: Major
Found in app/assets/javascripts/bookings_search_form.js and 1 other location - About 6 hrs to fix
app/assets/javascripts/user-event-search-form.js on lines 1..13

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

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

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

function highLight() {
  var fields = [
      'id',
      '_destroy',
      'day',
Severity: Major
Found in app/assets/javascripts/highlight.js - About 5 hrs to fix

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

        $('<button type="button" class="btn-floating btn-flat clockpicker-button am-button" tabindex="1">' + 'AM' + '</button>').on('click', function () {
          self.amOrPm = 'AM';
          self.amPmBlock.children('.pm-button').removeClass('active');
          self.amPmBlock.children('.am-button').addClass('active');
          self.spanAmPm.empty().append('AM');
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js and 1 other location - About 4 hrs to fix
app/assets/javascripts/materialize.clockpicker.js on lines 125..130

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

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

        $('<button type="button" class="btn-floating btn-flat clockpicker-button pm-button" tabindex="2">' + 'PM' + '</button>').on('click', function () {
          self.amOrPm = 'PM';
          self.amPmBlock.children('.am-button').removeClass('active');
          self.amPmBlock.children('.pm-button').addClass('active');
          self.spanAmPm.empty().append('PM');
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js and 1 other location - About 4 hrs to fix
app/assets/javascripts/materialize.clockpicker.js on lines 119..124

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

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

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

  ClockPicker.prototype.setHand = function (x, y, roundBy5, dragging) {
    var radian = Math.atan2(x, -y), isHours = this.currentView === 'hours', unit = Math.PI / (isHours || roundBy5 ? 6 : 30), z = Math.sqrt(x * x + y * y), options = this.options, inner = isHours && z < (outerRadius + innerRadius) / 2, radius = inner ? innerRadius : outerRadius, value;
    if (options.twelvehour) {
      radius = outerRadius;
    }
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js - About 3 hrs to fix

Block has too many lines. [59/25]
Open

Rails.application.routes.draw do
  root "welcome#index"

  scope path: "/events", controller: :events do
    get "popular"            => :popular
Severity: Minor
Found in config/routes.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

function initialize() {
  var mapOptions = {
    center: new google.maps.LatLng(-33.8688, 151.2195),
    zoom: 13
  };
Severity: Major
Found in app/assets/javascripts/maps.js - About 2 hrs to fix

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

        $('<div id="click-pm">PM</div>').on('click', function () {
          self.spanAmPm.children('#click-pm').addClass('text-primary');
          self.spanAmPm.children('#click-am').removeClass('text-primary');
          self.amOrPm = 'PM';
        }).appendTo(this.spanAmPm);
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/materialize.clockpicker.js on lines 133..137

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

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

        $('<div id="click-am">AM</div>').on('click', function () {
          self.spanAmPm.children('#click-am').addClass('text-primary');
          self.spanAmPm.children('#click-pm').removeClass('text-primary');
          self.amOrPm = 'AM';
        }).appendTo(this.spanAmPm);
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/materialize.clockpicker.js on lines 138..142

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

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

Function countdown has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

function countdown(val) {
  var minutes = val;
  $('#counter').css({
    'font-size': '3rem',
    'padding': '0 10px',
Severity: Minor
Found in app/assets/javascripts/countdown.js - 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

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

  ClockPicker.prototype.show = function (e) {
    // Not show again
    if (this.isShown) {
      return;
    }
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js - About 2 hrs to fix

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

        var isTouch = /^touch/.test(e.type), x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0, y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/materialize.clockpicker.js on lines 241..241

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

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

        var isTouch = /^touch/.test(e.type), x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0, y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js and 1 other location - About 2 hrs to fix
app/assets/javascripts/materialize.clockpicker.js on lines 229..229

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

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

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

    function mousedown(e, space) {
      var offset = plate.offset(), isTouch = /^touch/.test(e.type), x0 = offset.left + dialRadius, y0 = offset.top + dialRadius, dx = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0, dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0, z = Math.sqrt(dx * dx + dy * dy), moved = false;
      // When clicking on minutes view space, check the mouse position
      if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius)) {
        return;
Severity: Minor
Found in app/assets/javascripts/materialize.clockpicker.js - About 1 hr to fix

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

        tick.css({
          left: dialRadius + Math.sin(radian) * radius - tickRadius,
          top: dialRadius - Math.cos(radian) * radius - tickRadius
        });
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js and 2 other locations - About 1 hr to fix
app/assets/javascripts/materialize.clockpicker.js on lines 163..166
app/assets/javascripts/materialize.clockpicker.js on lines 193..196

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

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

      tick.css({
        left: dialRadius + Math.sin(radian) * outerRadius - tickRadius,
        top: dialRadius - Math.cos(radian) * outerRadius - tickRadius
      });
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js and 2 other locations - About 1 hr to fix
app/assets/javascripts/materialize.clockpicker.js on lines 163..166
app/assets/javascripts/materialize.clockpicker.js on lines 177..180

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

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

        tick.css({
          left: dialRadius + Math.sin(radian) * radius - tickRadius,
          top: dialRadius - Math.cos(radian) * radius - tickRadius
        });
Severity: Major
Found in app/assets/javascripts/materialize.clockpicker.js and 2 other locations - About 1 hr to fix
app/assets/javascripts/materialize.clockpicker.js on lines 177..180
app/assets/javascripts/materialize.clockpicker.js on lines 193..196

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

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