Showing 269 of 269 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (commandOptions.in) {
let relativePath = path.relative(this.project.root, commandOptions.in);
commandOptions.in = path.resolve(relativePath);
}
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function _addonTemplateFiles
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_addonTemplateFiles(addonTree) {
if (this._cachedAddonTemplateFiles) {
return this._cachedAddonTemplateFiles;
}
- Create a ticketCreate a ticket
Function compileAddon
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
compileAddon(tree) {
if (!this.options) {
throw new SilentError(
`Ember CLI addons manage their own module transpilation during the \`treeForAddon\` processing. ` +
`\`${this.name}\` (found at \`${this.root}\`) has removed \`this.options\` ` +
- Create a ticketCreate a ticket
Function memorySwapUsedLinux
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function memorySwapUsedLinux() {
try {
const { stdout } = execa.sync('free', ['-b']);
const lines = stdout.split('\n').filter(Boolean);
const header = lines.shift();
- Create a ticketCreate a ticket
Function addDependencies
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
addDependencies(dependencies) {
if (!dependencies) {
return null;
}
- Create a ticketCreate a ticket
Function build
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async build(addWatchDirCallback, resultAnnotation) {
await this.ensureBroccoliBuilder();
let buildResults, uiProgressIntervalID;
- Read upRead up
- Create a ticketCreate a ticket
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 getHostAddonInfo
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
getHostAddonInfo(packageInfoForLazyEngine) {
const cacheKey = `${this.project._packageInfo.realPath}-${packageInfoForLazyEngine.realPath}`;
let hostInfoCacheEntry = this._hostAddonInfoCache.get(cacheKey);
- Read upRead up
- Create a ticketCreate a ticket
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 fileMapTokens
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
fileMapTokens() {
return {
__name__(options) {
if (options.pod && options.hasPathToken) {
return options.locals.blueprintName;
- Read upRead up
- Create a ticketCreate a ticket
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 processAppMiddlewares
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
processAppMiddlewares(options) {
if (this.project.has(this.serverRoot)) {
try {
let server = this.project.require(this.serverRoot);
- Read upRead up
- Create a ticketCreate a ticket
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 _getBundledPackageInfos
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
_getBundledPackageInfos(pkgInfoToStartAt) {
let pkgInfos = this._bundledPackageInfoCache.get(pkgInfoToStartAt);
if (pkgInfos) {
return pkgInfos;
- Read upRead up
- Create a ticketCreate a ticket
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 addMiddleware
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
addMiddleware(config) {
let app = config.app;
let options = config.options;
let watcher = options.watcher;
let rootURL = options.rootURL === '' ? '/' : cleanBaseURL(options.rootURL);
- Create a ticketCreate a ticket
Function totalTime
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function totalTime(tree) {
let totalTime = 0;
let nodeItr;
let node;
let statName;
- Create a ticketCreate a ticket
Function didChange
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
didChange(results) {
let previousTree = this.tree;
let files;
if (results.stack) {
- Create a ticketCreate a ticket
Function processAppAndDependencies
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
processAppAndDependencies(allTrees) {
if (this._cachedProcessedAppAndDependencies === null) {
let config = this.packageConfig();
let internal = this.packageEmberCliInternalFiles();
let appContentsWithCompiledTemplates = this._debugTree(
- Create a ticketCreate a ticket
Function run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
run(options) {
const chalk = require('chalk');
let ui = this.ui;
let packageNames = options.packages || [];
let blueprintOptions = options.blueprintOptions || {};
- Create a ticketCreate a ticket
Function serverMiddleware
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
serverMiddleware(options) {
let app = options.app,
server = options.options.httpServer;
options = options.options;
- Create a ticketCreate a ticket
Function processFilesForUninstall
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
processFilesForUninstall(intoDir, templateVariables) {
let fileInfos = this._getFileInfos(this.files(this.options), intoDir, templateVariables);
this._ignoreUpdateFiles();
- Create a ticketCreate a ticket
Function addonCommands
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
addonCommands() {
const Command = require('../models/command');
let commands = Object.create(null);
this.addons.forEach((addon) => {
if (!addon.includedCommands) {
- Create a ticketCreate a ticket
Function run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async run(options) {
let cwd = process.cwd();
let name = options.rawName;
let blueprintOption = options.blueprint;
// If we're in a dry run, pretend we changed directories.
- Create a ticketCreate a ticket
Function configReplacePatterns
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function configReplacePatterns(options) {
return [
{
match: /{{\s?rootURL\s?}}/g,
replacement(config) {
- Create a ticketCreate a ticket