ember-cli/ember-cli

View on GitHub

Showing 269 of 269 total issues

Avoid too many return statements within this function.
Open

        return [];
Severity: Major
Found in lib/models/per-bundle-addon-cache/addon-proxy.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return Reflect.get(targetCacheEntry[TARGET_INSTANCE], property);
Severity: Major
Found in lib/models/per-bundle-addon-cache/addon-proxy.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return getAddonProxy(addonCacheEntry, parent);
Severity: Major
Found in lib/models/per-bundle-addon-cache/index.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

  return 'dependencies';
Severity: Major
Found in lib/utilities/format-package-list.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return () => undefined;
Severity: Major
Found in lib/models/per-bundle-addon-cache/addon-proxy.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return targetCacheEntry[TARGET_INSTANCE];
Severity: Major
Found in lib/models/per-bundle-addon-cache/addon-proxy.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return experimentValue !== 'false';
Severity: Major
Found in lib/experiments/index.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

  return false;
Severity: Major
Found in lib/utilities/is-lazy-engine.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return !!(
        addonCtorOrInstance.prototype.options.lazyLoading &&
        addonCtorOrInstance.prototype.options.lazyLoading.enabled === true
      );
Severity: Major
Found in lib/utilities/is-lazy-engine.js - About 30 mins to fix

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

      if (cacheEntry[TARGET_INSTANCE]) {
        logger.debug(`About to construct BR PROXY to cache entry for addon at: ${addonPkgInfo.realPath}`);
        this.numProxies++;
        return getAddonProxy(cacheEntry, parent);
      } else {
Severity: Minor
Found in lib/models/per-bundle-addon-cache/index.js and 1 other location - About 30 mins to fix
lib/models/per-bundle-addon-cache/index.js on lines 308..323

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

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

Avoid too many return statements within this function.
Open

  return class extends UnknownCommand {
    constructor(options) {
      super(options);
      this.name = commandName;
    }
Severity: Major
Found in lib/cli/lookup-command.js - About 30 mins to fix

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

        if (addonCacheEntry[TARGET_INSTANCE]) {
          logger.debug(`About to construct REGULAR ADDON PROXY for addon at: ${addonPkgInfo.realPath}`);
          this.numProxies++;
          return getAddonProxy(addonCacheEntry, parent);
        } else {
Severity: Minor
Found in lib/models/per-bundle-addon-cache/index.js and 1 other location - About 30 mins to fix
lib/models/per-bundle-addon-cache/index.js on lines 270..283

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

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 confirmOverwrite has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  confirmOverwrite(path) {
    let promptOptions = {
      type: 'expand',
      name: 'answer',
      default: false,
Severity: Minor
Found in lib/models/file-info.js - About 25 mins 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 _getAssetPath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  _getAssetPath(asset) {
    /* @type {String} */
    let assetPath;

    if (typeof asset !== 'object') {
Severity: Minor
Found in lib/broccoli/ember-app.js - About 25 mins 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 getBodyMsg has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function getBodyMsg(langArg) {
  return isValidCodeAndProg(langArg)
    ? getValidAndProgMsg(langArg)
    : isProgLang(langArg)
    ? getProgLangMsg(langArg)
Severity: Minor
Found in lib/utilities/get-lang-arg.js - About 25 mins 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 formatPackageList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function formatPackageList(packages) {
  if (Array.isArray(packages)) {
    if (packages.length === 1) {
      return packages[0];
    } else if (packages.length === 2) {
Severity: Minor
Found in lib/utilities/format-package-list.js - About 25 mins 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 setupMiddleware has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  setupMiddleware(options) {
    const tinylr = require('tiny-lr');
    const Server = tinylr.Server;

    if (options.liveReloadPrefix) {
Severity: Minor
Found in lib/tasks/server/livereload-server.js - About 25 mins 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 parseArgs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  parseArgs(commandArgs) {
    let knownOpts = {}; // Parse options
    let commandOptions = {};
    let parsedOptions;

Severity: Minor
Found in lib/models/command.js - About 25 mins 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 shouldHandleRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  shouldHandleRequest(req, options) {
    let acceptHeaders = req.headers.accept || [];
    let hasHTMLHeader = acceptHeaders.indexOf('text/html') !== -1;
    if (req.method !== 'GET') {
      return false;
Severity: Minor
Found in lib/tasks/server/middleware/history-support/index.js - About 25 mins 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 isValidParsedOption has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function isValidParsedOption(option, parsedOption) {
  // option.name didn't parse
  if (parsedOption === undefined) {
    // no default
    if (option.default === undefined) {
Severity: Minor
Found in lib/models/command.js - About 25 mins 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

Severity
Category
Status
Source
Language