Showing 700 of 1,230 total issues
Consider simplifying this complex logical expression. Open
if (tapEvt) {
var options = this.options,
fallbackTolerance = options.fallbackTolerance,
fallbackOffset = options.fallbackOffset,
touch = evt.touches ? evt.touches[0] : evt,
Function Sortable
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Sortable(el, options) {
if (!(el && el.nodeType && el.nodeType === 1)) {
throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
}
Class LandingPageController
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class LandingPageController < ActionController::Metal
# Shorthand for accessing CustomLandingPage service namespace
CLP = CustomLandingPage
Function initCategory
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initCategory() {
$(document).off('click', ".edit-dropdown-list-option-trigger");
$(document).on('click', '.edit-dropdown-list-option-trigger', function (event) {
var container = $(this).closest('.categories-list').next('.edit-category-content'),
remove = $(this).closest('.categories-list').next('.edit-category-content').next('.remove-category-content');
Function imageCarousel
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
ST.imageCarousel = function(images) {
// Elements
var tmpl = _.template($("#image-frame-template").html());
var leftLink = $("#listing-image-navi-left");
var rightLink = $("#listing-image-navi-right");
Method create
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def create
if new_listing_author != @current_user
logger.info "ADMIN ACTION: admin='#{@current_user.id}' create listing params=#{params.inspect}"
end
if show_location? && params[:listing][:origin_loc_attributes][:address].blank?
- Read upRead up
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 _onTapStart
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
_onTapStart: function _onTapStart(
/** Event|TouchEvent */
evt) {
if (!evt.cancelable) return;
File stripe_api_wrapper.rb
has 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
class StripeService::API::StripeApiWrapper
DEFAULT_MCC = 5734 # Computer Software Stores
API_2019_12_03 = '2019-12-03'.freeze
API_2019_02_19 = '2019-02-19'.freeze
Method give_consent
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
def give_consent
form_params = params[:form] || {}
values = Form.call(form_params.to_unsafe_hash)
invitation_check = -> {
File icon_map.rb
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
ICON_MAP = {
"ss-pika" => {
# Default UI icons
"details" => "ss-page",
Class CommunitiesController
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class Admin::CommunitiesController < Admin::AdminBaseController
include CommunitiesHelper
before_action :ensure_white_label_plan, only: [:create_sender_address]
Function renderImagePlaceholder
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
window.ST.renderImagePlaceholder = function() {
var template = $("#new-image-tmpl").html();
var element = $(template);
var previewImage = $("img", element).hide();
var removeLink = $('.fileupload-preview-remove-image', element);
Method create_message_from_action
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_message_from_action(transition, old_state, author, starter, payment_sum, payment_gateway, community, show_sum)
preauthorize_accepted = ->(new_state) { new_state == "paid" && old_state == "preauthorized" }
post_pay_accepted = ->(new_state) {
# The condition here is simply "if new_state is paid", since due to migrations from old system there might be
# transitions in "paid" state without previous state.
Method analytics_data
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def analytics_data
user_is_admin = @current_user.try(:is_marketplace_admin?, @current_community)
{
community_ident: @current_community.try(:ident),
community_uuid: @current_community.try(:uuid_object).to_s,
- Read upRead up
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
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def update
target_user = Person.find_by!(username: params[:id], community_id: @current_community.id)
if @current_user != target_user
logger.info "ADMIN ACTION: admin='#{@current_user.id}' update person='#{target_user.id}' params=#{params.inspect}"
end
- Read upRead up
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 validate_booking
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def validate_booking(tx_params:, quantity_selector:, stripe_in_use:)
per_hour = tx_params[:per_hour]
if per_hour || [:day, :night].include?(quantity_selector)
start_on, end_on = per_hour ? tx_params.values_at(:start_time, :end_time) : tx_params.values_at(:start_on, :end_on)
max_end_date = stripe_in_use ? APP_CONFIG.stripe_max_booking_date.days.from_now : 12.months.from_now
- Read upRead up
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 addListingMarkers
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addListingMarkers(listings, viewport) {
// Test requesting location data
// Now the request_path needs to also have a query string with the wanted parameters
markerContents = [];
Function submitHandler
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
submitHandler: function(form) {
removeSpaces();
stripeFormData = $(form).serializeArray();
var data = prepareData(options),
documentFrontEl = $('#stripe_account_form_document_front'),
Function draggable
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
function draggable(element, onmove, onstart, onstop) {
onmove = onmove || function () { };
onstart = onstart || function () { };
onstop = onstop || function () { };
var doc = document;
Function SwapPlugin
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SwapPlugin() {
function Swap() {
this.defaults = {
swapClass: 'sortable-swap-highlight'
};