andela/eventx

View on GitHub

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

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

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

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

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

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

Function countdown has 32 lines of code (exceeds 25 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 1 hr to fix

Method api_login has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def api_login
    token = params[:token]
    provider = params[:provider]
    if token.blank? || ENV[provider].nil?
      render_api_response(invalid_token, 417)
Severity: Minor
Found in app/controllers/sessions_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

Consider simplifying this complex logical expression.
Open

    if (place.address_components) {
      address = [
        place.address_components[0] && place.address_components[0].short_name || '',
        place.address_components[1] && place.address_components[1].short_name || '',
        place.address_components[2] && place.address_components[2].short_name || ''
Severity: Major
Found in app/assets/javascripts/maps.js - About 1 hr to fix

Method link_to_add_fields has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def link_to_add_fields(name, f, model_class, association, cssclass, title)
Severity: Minor
Found in app/helpers/bookings_helper.rb - About 45 mins to fix

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

  def ticket_quantity_specified?
    if ticket_params.values.map(&:to_i).inject(:+) <= 0
      flash[:notice] = ticket_quantity_empty
      redirect_to :back
    else
Severity: Minor
Found in app/controllers/bookings_controller.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 event_price has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def event_price(tickets, event)
    if user_is_attending_event(event)
      "Attending"
    elsif tickets.max == tickets.min
      tickets.max.zero? ? "Free" : number_to_currency(tickets.max, unit: "$")
Severity: Minor
Found in app/helpers/events_helper.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