pivorakmeetup/pivorak-web-app

View on GitHub

Showing 9 of 12 total issues

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

  var loadFlash = function() {
    var animationEnd = whichAnimationEvent();
    var mainFlashNode = document.getElementById('main-flash');

    var flashBackDrop = document.createElement("div");
Severity: Minor
Found in app/assets/javascripts/app/flash.js - About 1 hr to fix

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

  var initDropdowns = function() {

    function whichTransitionEvent(){
      var t;
      var el = document.createElement('fakeelement');
Severity: Minor
Found in app/assets/javascripts/app/dropdowns.js - About 1 hr to fix

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

  var initChangeImageColor = function() {
    var elements = document.querySelectorAll('.pk-js-changed-color-images');

    for(var i = 0; i < elements.length; i++) {
      var elem = elements[i];
Severity: Minor
Found in app/assets/javascripts/app/change_img_color.js - About 1 hr to fix

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

  def attend_event_link(event, visit_request)
    return unless current_user

    return if visit_request&.pending?
    return if visit_request&.approved?
Severity: Minor
Found in app/helpers/events_helper.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

Avoid too many return statements within this method.
Open

    return if event.visitors.include?(current_user)
Severity: Major
Found in app/helpers/events_helper.rb - About 30 mins to fix

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

      def expect_an_error(hash_pair = {}, nope = false) # rubocop:disable Metrics/AbcSize
        field = hash_pair.keys.first
        value = hash_pair.values.first
        error_div = "div.#{field}.field_with_errors"

Severity: Minor
Found in components/courses/spec/support/features_helpers.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 expect_an_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def expect_an_error(hash_pair = {}, nope = false) # rubocop:disable Metrics/AbcSize
  field     = hash_pair.keys.first
  value     = hash_pair.values.first
  error_div = "div.#{field}.error"

Severity: Minor
Found in spec/support/features_support.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 visit_request_confirm_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def visit_request_confirm_message(visit_request)
    return unless visit_request && current_user

    if visit_request.confirmed?
      t('visit_requests.messages.see_you')
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

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

    def call # rubocop:disable Metrics/AbcSize
      return VisitRequest::Approve.call(visit_request) if user.verified? && policy.free_slot_for?(user)

      VisitRequestMailer.needs_confirmation(visit_request).deliver_later unless user.verified?
      visit_request.pending!
Severity: Minor
Found in app/services/visit_request/create.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