ember-cli/ember-cli

View on GitHub
lib/models/addon.js

Summary

Maintainability
F
3 days
Test Coverage
A
93%

addonProto has 47 functions (exceeds 20 allowed). Consider refactoring.
Open

let addonProto = {
  /**
    The name of this addon.

    @public
Severity: Minor
Found in lib/models/addon.js - About 6 hrs to fix

Function jshintAddonTree has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  jshintAddonTree() {
    let trees = [];

    let addonPath = this._treePathFor('addon');
    if (fs.existsSync(addonPath)) {
Severity: Minor
Found in lib/models/addon.js - About 1 hr to fix

Function init has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  init(parent, project) {
    this._super();
    this.parent = parent;
    this.project = project;
    this.ui = project && project.ui;
Severity: Minor
Found in lib/models/addon.js - About 1 hr to fix

Function isDevelopingAddon has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  isDevelopingAddon() {
    if (process.env.EMBER_ADDON_ENV === 'development' && this.parent instanceof Project) {
      const parentName = this.parent.name();
      // If the name in package.json and index.js match, we're definitely developing
      if (parentName === this.name) {
Severity: Minor
Found in lib/models/addon.js - About 1 hr 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 _fileSystemInfo has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _fileSystemInfo() {
    if (this._cachedFileSystemInfo) {
      return this._cachedFileSystemInfo;
    }

Severity: Minor
Found in lib/models/addon.js - About 1 hr to fix

Function treeFor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  treeFor(treeType) {
    let node = heimdall.start({
      name: `treeFor(${this.name} - ${treeType})`,
      addonName: this.name,
      treeType,
Severity: Minor
Found in lib/models/addon.js - About 1 hr to fix

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\` ` +
Severity: Minor
Found in lib/models/addon.js - About 1 hr to fix

Function _addonTemplateFiles has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _addonTemplateFiles(addonTree) {
    if (this._cachedAddonTemplateFiles) {
      return this._cachedAddonTemplateFiles;
    }

Severity: Minor
Found in lib/models/addon.js - About 1 hr to fix

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

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

    if (fs.existsSync(appPath)) {
      let appTree = new Funnel(appPath, { destDir: 'app' });
      let lintAppJsTrees = this._eachProjectAddonInvoke('lintTree', ['app', appTree]);
      trees = trees.concat(lintAppJsTrees);
    }
Severity: Major
Found in lib/models/addon.js and 2 other locations - About 1 hr to fix
lib/models/addon.js on lines 1187..1194
lib/models/addon.js on lines 1204..1208

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

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 3 locations. Consider refactoring.
Open

    if (fs.existsSync(testSupportPath)) {
      let testSupportTree = new Funnel(testSupportPath, { destDir: 'test-support' });
      let lintTestSupportJsTrees = this._eachProjectAddonInvoke('lintTree', ['test-support', testSupportTree]);
      trees = trees.concat(lintTestSupportJsTrees);
    }
Severity: Major
Found in lib/models/addon.js and 2 other locations - About 1 hr to fix
lib/models/addon.js on lines 1187..1194
lib/models/addon.js on lines 1197..1201

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

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 3 locations. Consider refactoring.
Open

    if (fs.existsSync(addonTestSupportPath)) {
      let addonTestSupportTree = new Funnel(addonTestSupportPath, { destDir: 'addon-test-support' });
      let lintAddonTestSupportJsTrees = this._eachProjectAddonInvoke('lintTree', [
        'addon-test-support',
        addonTestSupportTree,
Severity: Major
Found in lib/models/addon.js and 2 other locations - About 1 hr to fix
lib/models/addon.js on lines 1197..1201
lib/models/addon.js on lines 1204..1208

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

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 3 locations. Consider refactoring.
Open

      standardTemplates = new Funnel(addonTemplates, {
        srcDir: '/',
        destDir: `${this.moduleName()}/templates`,
        annotation: `Addon#_addonTemplateFiles (${this.name})`,
      });
Severity: Major
Found in lib/models/addon.js and 2 other locations - About 50 mins to fix
lib/models/addon.js on lines 881..885
lib/models/addon.js on lines 901..905

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

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 3 locations. Consider refactoring.
Open

    return new Funnel(tree, {
      srcDir: '/',
      destDir: `/${this.moduleName()}`,
      annotation: `Addon#treeForPublic (${this.name})`,
    });
Severity: Major
Found in lib/models/addon.js and 2 other locations - About 50 mins to fix
lib/models/addon.js on lines 901..905
lib/models/addon.js on lines 1049..1053

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

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 3 locations. Consider refactoring.
Open

    let namespacedTree = new Funnel(tree, {
      srcDir: '/',
      destDir: `/${this.moduleName()}/test-support`,
      annotation: `Addon#treeForTestSupport (${this.name})`,
    });
Severity: Major
Found in lib/models/addon.js and 2 other locations - About 50 mins to fix
lib/models/addon.js on lines 881..885
lib/models/addon.js on lines 1049..1053

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

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 3 locations. Consider refactoring.
Open

    if (!this.options.babel) {
      throw new SilentError(
        `Ember CLI addons manage their own module transpilation during the \`treeForAddon\` processing. ` +
          `\`${this.name}\` (found at \`${this.root}\`) has overridden the \`this.options.babel\` options ` +
          `which conflicts with the addons ability to transpile its \`addon/\` files properly.`
Severity: Major
Found in lib/models/addon.js and 2 other locations - About 45 mins to fix
lib/models/addon.js on lines 1122..1128
lib/models/addon.js on lines 1138..1144

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

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 3 locations. Consider refactoring.
Open

    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\` ` +
          `which conflicts with the addons ability to transpile its \`addon/\` files properly.`
Severity: Major
Found in lib/models/addon.js and 2 other locations - About 45 mins to fix
lib/models/addon.js on lines 1130..1136
lib/models/addon.js on lines 1138..1144

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

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 3 locations. Consider refactoring.
Open

    if (!this.options['ember-cli-babel']) {
      throw new SilentError(
        `Ember CLI addons manage their own module transpilation during the \`treeForAddon\` processing. ` +
          `\`${this.name}\` (found at \`${this.root}\`) has overridden the \`this.options['ember-cli-babel']\` options ` +
          `which conflicts with the addons ability to transpile its \`addon/\` files properly.`
Severity: Major
Found in lib/models/addon.js and 2 other locations - About 45 mins to fix
lib/models/addon.js on lines 1122..1128
lib/models/addon.js on lines 1130..1136

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

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

  _getAddonTreeFiles() {
    let addonTreePath = this._treePathFor('addon');

    if (fs.existsSync(addonTreePath)) {
      return walkSync(addonTreePath);
Severity: Minor
Found in lib/models/addon.js and 1 other location - About 40 mins to fix
lib/models/addon.js on lines 1029..1037

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

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

  _getAddonTemplatesTreeFiles() {
    let addonTemplatesTreePath = this._treePathFor('addon-templates');

    if (fs.existsSync(addonTemplatesTreePath)) {
      return walkSync(addonTemplatesTreePath);
Severity: Minor
Found in lib/models/addon.js and 1 other location - About 40 mins to fix
lib/models/addon.js on lines 1019..1027

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

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

There are no issues that match your filters.

Category
Status