ember-cli/ember-cli

View on GitHub

Showing 269 of 269 total issues

Function run has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async run(environmentPromiseHash) {
    if (environmentPromiseHash === undefined) {
      return Promise.reject(new Error('Unable to execute "run" command without environment argument'));
    }
    let shutdownOnExit = null;
Severity: Major
Found in lib/cli/cli.js - About 2 hrs to fix

Function createBlueprints has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async createBlueprints(options) {
    let name = options.args[0];
    let noAddonBlueprint = ['mixin', 'blueprint-test'];

    let entity = {
Severity: Major
Found in lib/tasks/generate-from-blueprint.js - About 2 hrs to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  memorySwapUsed(platform = process.platform) {
    switch (platform) {
      case 'darwin':
        return memorySwapUsedDarwin();

Severity: Major
Found in lib/models/hardware-info.js and 1 other location - About 2 hrs to fix
lib/models/hardware-info.js on lines 245..264

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 90.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  isUsingBattery(platform = process.platform) {
    switch (platform) {
      case 'darwin':
        return isUsingBatteryDarwin();

Severity: Major
Found in lib/models/hardware-info.js and 1 other location - About 2 hrs to fix
lib/models/hardware-info.js on lines 276..295

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 90.

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

Further Reading

PackageInfo has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class PackageInfo {
  constructor(pkgObj, realPath, cache, isRoot = false) {
    this.pkg = pkgObj;
    this.pkg['ember-addon'] = this.pkg['ember-addon'] || {};
    this.realPath = realPath;
Severity: Minor
Found in lib/models/package-info-cache/package-info.js - About 2 hrs to fix

Function _import has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _import(assetPath, options, directory, subdirectory, extension) {
    // TODO: refactor, this has gotten very messy. Relevant tests: tests/unit/broccoli/ember-app-test.js
    let basename = path.basename(assetPath);

    if (p.isType(assetPath, 'js', { registry: this.registry })) {
Severity: Major
Found in lib/broccoli/ember-app.js - About 2 hrs to fix

Function exports has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (initialMargin, shouldDescriptionBeGrey) {
  initialMargin = initialMargin || '';

  let output = '';

Severity: Major
Found in lib/utilities/print-command.js - About 2 hrs to fix

Function _fileMapTokens has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  _fileMapTokens(options) {
    let { project } = this;
    let standardTokens = {
      __name__(options) {
        if (options.pod && options.hasPathToken) {
Severity: Minor
Found in lib/models/blueprint.js - About 2 hrs to fix

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 contentFor has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function contentFor(config, match, type, options) {
  let content = [];

  // This normalizes `rootURL` to the value which we use everywhere inside of Ember CLI.
  // This makes sure that the user doesn't have to account for it in application code.
Severity: Major
Found in lib/utilities/ember-app-utils.js - About 2 hrs to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      addonPromises = this.project.addons.reduce((sum, addon) => {
        let method = addon[buildStep];
        if (method) {
          let val = method.call(addon, results);
          if (val) {
Severity: Major
Found in lib/models/builder.js and 1 other location - About 2 hrs to fix
lib/models/addon.js on lines 497..506

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 81.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      if (this.options.addons.include && this.options.addons.include.length) {
        throw new Error(
          [
            `[ember-cli] addon bundle caching is disabled for apps that specify an addon "include"`,
            '',
Severity: Major
Found in lib/broccoli/ember-app.js and 1 other location - About 2 hrs to fix
lib/broccoli/ember-app.js on lines 167..176

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 81.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      if (this.options.addons.exclude && this.options.addons.exclude.length) {
        throw new Error(
          [
            `[ember-cli] addon bundle caching is disabled for apps that specify an addon "exclude"`,
            '',
Severity: Major
Found in lib/broccoli/ember-app.js and 1 other location - About 2 hrs to fix
lib/broccoli/ember-app.js on lines 156..165

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 81.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    return this.project.addons.reduce((sum, addon) => {
      let method = addon[methodName];
      if (method) {
        let val = method.apply(addon, invokeArguments);
        if (val) {
Severity: Major
Found in lib/models/addon.js and 1 other location - About 2 hrs to fix
lib/models/builder.js on lines 154..163

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 81.

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

Further Reading

Function mergeTrees has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function mergeTrees(_inputTrees, options) {
  options = options || {};

  let node = heimdall.start(
    {
Severity: Major
Found in lib/broccoli/merge-trees.js - About 2 hrs to fix

Function insertIntoFile has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function insertIntoFile(fullPath, contentsToInsert, providedOptions) {
  let options = providedOptions || {};

  let returnValue = {
    path: fullPath,
Severity: Major
Found in lib/utilities/insert-into-file.js - About 2 hrs to fix

Function createBlueprints has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  async createBlueprints(options) {
    let name = options.args[0];
    let noAddonBlueprint = ['mixin', 'blueprint-test'];

    let entity = {
Severity: Minor
Found in lib/tasks/generate-from-blueprint.js - About 2 hrs to fix

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 getAddonInstance has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getAddonInstance(parent, addonPkgInfo) {
    // If the new addon is itself a bundle host (i.e. lazy engine), there is only one
    // instance of the bundle host, and it's in the entries of the bundleHostCache, outside
    // of the 'regular' addon caches. Because 'setupBundleHostCache' ran during construction,
    // we know that an entry is in the cache with this engine name.
Severity: Major
Found in lib/models/per-bundle-addon-cache/index.js - About 2 hrs to fix

Function getAddonProxy has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getAddonProxy(targetCacheEntry, parent) {
  let _app;

  // handle `preprocessJs` separately for Embroider
  //
Severity: Major
Found in lib/models/per-bundle-addon-cache/addon-proxy.js - About 2 hrs to fix

Function run has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async run(options) {
    let hasBuild = !!options.path;

    if (hasBuild) {
      if (!fs.existsSync(options.path)) {
Severity: Major
Found in lib/tasks/serve.js - About 2 hrs to fix

Function locals has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  locals(options) {
    let entity = { name: 'dummy' };
    let rawName = entity.name;
    let name = stringUtil.dasherize(rawName);
    let namespace = stringUtil.classify(rawName);
Severity: Major
Found in blueprints/addon/index.js - About 2 hrs to fix
Severity
Category
Status
Source
Language