Showing 12 of 27 total issues
Class User
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
has_many :artisan_skillsets, foreign_key: :artisan_id
has_many :skillsets, through: :artisan_skillsets
has_many :reviews
has_many :reviewers, class_name: "Review", foreign_key: :reviewer_id
Function initLocationMap
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initLocationMap () {
if (!navigator.geolocation) {
window.alert('Geolocation not supported by this browser')
}
Function initUserMap
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initUserMap() {
var latitude, longitude;
$('.user-map-trigger').on('click', function() {
latitude = $(this).data("latitude")
longitude = $(this).data("longitude")
Method user_info
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def user_info(data, current_user)
birthday = get_user_birthday(data[:date])
city = current_user.city if data[:city] == "City"
state = current_user.state if data[:state] == "State"
gender = current_user.gender if data[:gender] == "Gender"
- 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 review_and_rate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def review_and_rate(params)
review = Review.new
if params[:user_id] && current_user.id
review.rating = params[:rating] if params[:rating]
review.reviewer_id = current_user.id
- 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 text_tags
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def text_tags(name, value = "", holder = "", class_name = "", req = false,
disabled = false)
Method email_tags
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def email_tags(name, value = "", holder = "", class_name = "", req = false,
disabled = false)
Method send_notifications
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
user,
task,
task_category,
notification_artisan,
notification_tasker
Method end_time_must_be_later_than_start_time
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def end_time_must_be_later_than_start_time
if start_time && end_time
unless end_time > start_time && end_time > Time.now
errors[:endtime] = "End_time cannot be in the past"
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 get_user_birthday
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_user_birthday(data)
if data
day = data[:day]
month = data[:month]
year = data[:year]
- 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 search
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def search
if params[:searcher] || session[:searcher]
session[:searcher] = params[:searcher] if params[:searcher]
@artisans = get_artisans_by_search(session[:searcher])
skillset = Skillset.where("LOWER(name) LIKE ?",
- 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 check_price_range
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_price_range
min_price, max_price = price_range.map(&:to_i)
value_error_message = "Prices must be greater than $2000"
comparison_error_message = "Minimum price must be less than the maximum"
- 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"