Showing 17 of 66 total issues
Method get_bad_word
has 597 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_bad_word
bad_words = ["babaca",
"babacÊo",
"babacão",
"babacaum",
File application_helper.rb
has 639 lines of code (exceeds 250 allowed). Consider refactoring. Open
module ApplicationHelper
def set_average_style(average)
case average
when "Péssimo"
Method create
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def create
if params[:accepted_terms] && params[:rating][:rating_date] && params[:rating][:cpf]
if Obscenity.profane?(rating_params[:description])
redirect_to controller: :ratings, action: :new, placeId: params[:placeId]
- 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 initAutocomplete
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initAutocomplete () {
var mapField = $('#map')[0]
map = new google.maps.Map(mapField, {
center: {lat: -30.0277, lng: -51.2287},
zoom: 12
Consider simplifying this complex logical expression. Open
if ( strCPF === '00000000000' || strCPF === '11111111111' || strCPF === '22222222222' || strCPF === '33333333333' || strCPF === '44444444444' || strCPF === '55555555555' || strCPF === '66666666666' || strCPF === '77777777777' || strCPF === '88888888888' || strCPF === '99999999999' || strCPF === '01234567890') return true;
File welcome.js
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
//= require header-mobile
var autocomplete;
var map;
Function patternLinks
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function patternLinks(){
$('#abuse-first').click(function(){
$('#article-1').fadeToggle("slow");
$('#discriminacao_down').toggleClass('hidden');
$('#discriminacao_right').toggleClass('hidden');
Consider simplifying this complex logical expression. Open
if(!(errors['cpfEvaluate'] || isNull($('#cpfEvaluate')) || errors['rating'] || isNull($('#dateEvaluate')) || errors['dateEvaluate'] || errors['nameEvaluate'] || errors['emailEvaluate'] || errors['description'])){
enableButtonTerms(); }
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
if params[:accepted_terms] && params[:rating][:rating_date] && params[:rating][:cpf]
if Obscenity.profane?(rating_params[:description])
redirect_to controller: :ratings, action: :new, placeId: params[:placeId]
Function createPin
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createPin(){
for(var i = 0; i<locations.length; i++){
var locate = locations[i];
var iconColor = locate[3];
var myLatLng = {lat: locate[1], lng: locate[2]};
Avoid deeply nested control flow statements. Open
@rating.description.empty? ? notice = "Avaliação feita com sucesso!" : notice = "Avaliação feita com sucesso! Sua avaliação irá passar pela moderação."
Consider simplifying this complex logical expression. Open
if(!(@rating.woman.nil? && @rating.lgbtqia.nil? && @rating.race.nil? && @rating.disability.nil? && @rating.elder.nil? && @rating.obese.nil?))
if(@establishment.nil?)
@place = @client.spot(params[:placeId])
@establishment = Establishment.create!(name: @place.name, address: @place.formatted_address, lat: @place.lat, lng: @place.lng, id_places: @place.place_id, city: @place.city)
end
Avoid too many return
statements within this method. Open
return nil
Avoid too many return
statements within this method. Open
return 'concept-excellent'
Method moderated
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def moderated
respond_to do |format|
if(@rating.moderated == false)
@rating.moderated = true
else
- 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 generate_concept
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_concept(establishment)
if establishment.has_more_than_2_ratings?
general_average = []
establishment.ratings.each do |rating|
- 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 populate_rate_array
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def populate_rate_array(ratings)
rate_array = []
ratings.each do |rating|
if rating.average_rating < 1.8
rate_array.push([rating,"Péssimo"])
- 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"