This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *SMELL* | |
function mutableData() { | |
let name = { | |
firstName: "Rafael", | |
lastName: "Melo" | |
}; | |
name = `${name.firstName} ${name.lastName}`; | |
return name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *SMELL* | |
function ballSports() { | |
const playersTypes = [ | |
{name: "soccerPlayers", usesFeet: true, usesHands: false}, | |
{name: "basketPlayers", usesFeet: false, usesHands: true}, | |
{name: "volleyPlayers", usesFeet: false, usesHands: true}, | |
{name: "hockeyPlayers", usesFeet: false, usesHands: false} | |
// WHAT IF WE NEED TO ADD {name: "baseballPlayers", usesFeet: false, usesHands: false} ? | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *SMELL* | |
function convertTemperatures(farenheit, celcius, kelvin) { | |
const farenheitToCelcius = (5 / 9) * (farenheit - 32); | |
const farenheitToKelvin = ((farenheit - 32) / 1.8) + 273.15; | |
const celciusToFarenheit = (celcius * 1.8) + 32; | |
const celciusToKelvin = celcius + 273.15; | |
const kelvinToFarenheit = kelvin * 1.8 - 459.67; | |
const kelvinToCelcius = kelvin - 273.15; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *SMELL* | |
function generateUsername(userId, name, email, username, phone, address, country, age) { | |
return { | |
username: username || `${name}_${age}`, | |
userId, | |
name, | |
email, | |
phone, | |
address, | |
country, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *SMELL* | |
// Our program only needs farenheit to celcius, but the programmer thinks: what if in the future we need every temperature? | |
// He searches on google and add modules to every temparature he can find. But what happens is that in 5 years the program is | |
// only used with celsius to farenheit and the modules he wrote thinking in the future actually is never used, not even once. | |
function convertToCelcius(temperature) { | |
const farenheitConversion = (5 / 9) * (temperature - 32); | |
const kelvinConversion = temperature - 273.15; | |
const rankineConversion = (temperature - 491.67) * (5 / 9); | |
const reaumurConversion = temperature * 1.25; | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BEFORE | |
function printOwing(invoice) { | |
printBanner(); | |
const outstanding = calculateOutstanding(); | |
//print details | |
console.log(`name: ${invoice.custome},`); | |
console.log(`amount: ${outstanding},`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
function getRating(driver) { | |
return moreThanFiveLateDeliveries(driver) ? 2 : 1; | |
} | |
function moreThanFiveLateDeliveries(driver) { | |
return driver.numberOfLateDeliveries > 5; | |
} | |
//AFTER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
function extractVariable(order) { | |
return order.quantity * order.itemPrice - | |
Math.max(0, order.quantity - 500) * order.itemPrice * 0.05 + | |
Math.min(order.quantity * order.itemPrice *0.1, 100) | |
} | |
//AFTER | |
function extractVariable(order) { | |
const basePrice = order.quantity * order.itemPrice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
function inlineVariable(order) { | |
const basePrice = order.basePrice; | |
return basePrice > 1000; | |
} | |
//AFTER | |
function inlineVariable(order) { | |
return order.basePrice > 1000; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
function circum(radius) { | |
return 2 * Math.PI * radius; | |
} | |
//AFTER | |
function circumference(radius) { | |
return 2 * Math.PI * radius; | |
} |