meteor/meteor

View on GitHub
tools/cordova/project.js

Summary

Maintainability
F
4 days
Test Coverage

File project.js has 651 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _ from 'underscore';
import util from 'util';
import assert from 'assert';
import chalk from 'chalk';
import semver from 'semver';
Severity: Major
Found in tools/cordova/project.js - About 1 day to fix

    Function ensurePluginsAreSynchronized has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      ensurePluginsAreSynchronized(pluginVersions, pluginsConfiguration = {}) {
        assert(pluginVersions);
    
        buildmessage.assertInCapture();
    
    
    Severity: Major
    Found in tools/cordova/project.js - About 3 hrs to fix

      CordovaProject has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class CordovaProject {
        constructor(projectContext, options = {}) {
      
          this.projectContext = projectContext;
      
      
      Severity: Minor
      Found in tools/cordova/project.js - About 3 hrs to fix

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

          checkPlatformRequirements(platform) {
            if (platform === 'ios' && process.platform !== 'darwin') {
              Console.warn("Currently, it is only possible to build iOS apps \
        on an OS X system.");
              return false;
        Severity: Minor
        Found in tools/cordova/project.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 checkPlatformRequirements has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          checkPlatformRequirements(platform) {
            if (platform === 'ios' && process.platform !== 'darwin') {
              Console.warn("Currently, it is only possible to build iOS apps \
        on an OS X system.");
              return false;
        Severity: Major
        Found in tools/cordova/project.js - About 2 hrs to fix

          Function createIfNeeded has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            createIfNeeded() {
              buildmessage.assertInJob();
          
              // Check if we have an existing Cordova project directory with outdated
              // platforms. In that case, we remove the whole directory to avoid issues.
          Severity: Major
          Found in tools/cordova/project.js - About 2 hrs to fix

            Function createIfNeeded has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              createIfNeeded() {
                buildmessage.assertInJob();
            
                // Check if we have an existing Cordova project directory with outdated
                // platforms. In that case, we remove the whole directory to avoid issues.
            Severity: Minor
            Found in tools/cordova/project.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 runCommands has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              runCommands(title, promiseOrAsyncFunction, env = this.defaultEnvWithPathsAdded(),
                cwd = this.projectRoot) {
                // Capitalize title for debug output
                Console.debug(title[0].toUpperCase() + title.slice(1));
            
            
            Severity: Minor
            Found in tools/cordova/project.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 runCommands has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              runCommands(title, promiseOrAsyncFunction, env = this.defaultEnvWithPathsAdded(),
                cwd = this.projectRoot) {
                // Capitalize title for debug output
                Console.debug(title[0].toUpperCase() + title.slice(1));
            
            
            Severity: Minor
            Found in tools/cordova/project.js - About 1 hr to fix

              Function prepareFromAppBundle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                prepareFromAppBundle(bundlePath, pluginVersions) {
                  assert(bundlePath);
                  assert(pluginVersions);
              
                  buildmessage.assertInJob();
              Severity: Minor
              Found in tools/cordova/project.js - About 1 hr to fix

                Function addPlugin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  addPlugin(id, version, config = {}, options = {}) {
                    const { retry = true } = options;
                    const target = this.targetForPlugin(id, version, options);
                    if (target) {
                      const commandOptions = Object.assign(this.defaultOptions,
                Severity: Minor
                Found in tools/cordova/project.js - About 35 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 targetForPlugin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  targetForPlugin(id, version, { usePluginName = false } = {}) {
                    assert(id);
                    assert(version);
                
                    buildmessage.assertInJob();
                Severity: Minor
                Found in tools/cordova/project.js - About 35 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

                Avoid too many return statements within this function.
                Open

                    return satisfied;
                Severity: Major
                Found in tools/cordova/project.js - About 30 mins to fix

                  Function ensurePlatformsAreSynchronized has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    ensurePlatformsAreSynchronized(platforms = this.cordovaPlatformsInApp) {
                      buildmessage.assertInCapture();
                  
                      const installedPlatforms = this.listInstalledPlatforms();
                  
                  
                  Severity: Minor
                  Found in tools/cordova/project.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

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

                        { mobileServerUrl: this.options.mobileServerUrl,
                          cordovaServerPort: this.options.cordovaServerPort,
                          settingsFile: this.options.settingsFile,
                          buildMode: this.options.buildMode }
                  Severity: Minor
                  Found in tools/cordova/project.js and 1 other location - About 55 mins to fix
                  tools/cordova/project.js on lines 178..181

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

                  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

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

                          { mobileServerUrl: this.options.mobileServerUrl,
                            cordovaServerPort: this.options.cordovaServerPort,
                            settingsFile: this.options.settingsFile,
                            buildMode: this.options.buildMode }
                  Severity: Minor
                  Found in tools/cordova/project.js and 1 other location - About 55 mins to fix
                  tools/cordova/project.js on lines 255..258

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

                  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

                    updatePlatforms(platforms = this.listInstalledPlatforms()) {
                      this.runCommands(`updating Cordova project for platforms \
                  ${displayNamesForPlatforms(platforms)}`, async () => {
                        await cordova_lib.platform('update', platforms, this.defaultOptions);
                      });
                  Severity: Minor
                  Found in tools/cordova/project.js and 1 other location - About 55 mins to fix
                  tools/cordova/project.js on lines 457..462

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

                  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

                    removePlatform(platform) {
                      this.runCommands(`removing platform ${displayNameForPlatform(platform)} \
                  from Cordova project`, async () => {
                        await cordova_lib.platform('rm', platform, this.defaultOptions);
                      });
                  Severity: Minor
                  Found in tools/cordova/project.js and 1 other location - About 55 mins to fix
                  tools/cordova/project.js on lines 441..446

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

                  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

                          const androidJson = files.exists(androidJsonPath) ? JSON.parse(files.readFile(
                            androidJsonPath, 'utf8')) : { installed_plugins: {} };
                  Severity: Minor
                  Found in tools/cordova/project.js and 1 other location - About 30 mins to fix
                  tools/cordova/project.js on lines 717..718

                  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

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

                          const iosJson = files.exists(iosJsonPath) ? JSON.parse(files.readFile(
                            iosJsonPath, 'utf8')) : { installed_plugins: {} };
                  Severity: Minor
                  Found in tools/cordova/project.js and 1 other location - About 30 mins to fix
                  tools/cordova/project.js on lines 715..716

                  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

                  There are no issues that match your filters.

                  Category
                  Status