adobe/brackets

View on GitHub
src/language/LanguageManager.js

Summary

Maintainability
F
4 days
Test Coverage

File LanguageManager.js has 553 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
Severity: Major
Found in src/language/LanguageManager.js - About 1 day to fix

    Function defineLanguage has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function defineLanguage(id, definition) {
            var result = new $.Deferred();
    
            if (_pendingLanguages[id]) {
                result.reject("Language \"" + id + "\" is waiting to be resolved.");
    Severity: Major
    Found in src/language/LanguageManager.js - About 2 hrs to fix

      Function _updateFromPrefs has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function _updateFromPrefs(pref) {
              var newMapping = PreferencesManager.get(pref),
                  newNames = Object.keys(newMapping),
                  state = _prefState[pref],
                  last = state.last,
      Severity: Minor
      Found in src/language/LanguageManager.js - About 1 hr to fix

        Function _loadAndSetMode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            Language.prototype._loadAndSetMode = function (mode) {
                var result      = new $.Deferred(),
                    self        = this,
                    mimeMode; // Mode can be an array specifying a mode plus a MIME mode defined by that mode ["clike", "text/x-c++src"]
        
        
        Severity: Minor
        Found in src/language/LanguageManager.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                  if (!language._setId(id) || !language._setName(name) ||
                          (blockComment && !language.setBlockCommentSyntax(blockComment[0], blockComment[1])) ||
                          (lineComment && !language.setLineCommentSyntax(lineComment))) {
                      result.reject();
                      return result.promise();
          Severity: Major
          Found in src/language/LanguageManager.js - About 40 mins to fix

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

                    if (this._fileNames.indexOf(name) === -1) {
                        this._fileNames.push(name);
            
                        var language = _fileNameToLanguageMap[name];
                        if (language) {
            Severity: Major
            Found in src/language/LanguageManager.js and 1 other location - About 3 hrs to fix
            src/language/LanguageManager.js on lines 658..674

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

            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._fileExtensions.indexOf(extension) === -1) {
                        this._fileExtensions.push(extension);
            
                        var language = _fileExtensionToLanguageMap[extension];
                        if (language) {
            Severity: Major
            Found in src/language/LanguageManager.js and 1 other location - About 3 hrs to fix
            src/language/LanguageManager.js on lines 722..733

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

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

                Language.prototype.addFileExtension = function (extension) {
                    if (Array.isArray(extension)) {
                        extension.forEach(this._addFileExtension.bind(this));
                    } else {
                        this._addFileExtension(extension);
            Severity: Major
            Found in src/language/LanguageManager.js and 3 other locations - About 2 hrs to fix
            src/language/LanguageManager.js on lines 681..687
            src/language/LanguageManager.js on lines 711..717
            src/language/LanguageManager.js on lines 740..746

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

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

                Language.prototype.removeFileExtension = function (extension) {
                    if (Array.isArray(extension)) {
                        extension.forEach(this._removeFileExtension.bind(this));
                    } else {
                        this._removeFileExtension(extension);
            Severity: Major
            Found in src/language/LanguageManager.js and 3 other locations - About 2 hrs to fix
            src/language/LanguageManager.js on lines 642..648
            src/language/LanguageManager.js on lines 711..717
            src/language/LanguageManager.js on lines 740..746

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

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

                Language.prototype.addFileName = function (name) {
                    if (Array.isArray(name)) {
                        name.forEach(this._addFileName.bind(this));
                    } else {
                        this._addFileName(name);
            Severity: Major
            Found in src/language/LanguageManager.js and 3 other locations - About 2 hrs to fix
            src/language/LanguageManager.js on lines 642..648
            src/language/LanguageManager.js on lines 681..687
            src/language/LanguageManager.js on lines 740..746

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

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

                Language.prototype.removeFileName = function (name) {
                    if (Array.isArray(name)) {
                        name.forEach(this._removeFileName.bind(this));
                    } else {
                        this._removeFileName(name);
            Severity: Major
            Found in src/language/LanguageManager.js and 3 other locations - About 2 hrs to fix
            src/language/LanguageManager.js on lines 642..648
            src/language/LanguageManager.js on lines 681..687
            src/language/LanguageManager.js on lines 711..717

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

            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 (fileExtensions) {
                            for (i = 0, l = fileExtensions.length; i < l; i++) {
                                language.addFileExtension(fileExtensions[i]);
                            }
                        }
            Severity: Minor
            Found in src/language/LanguageManager.js and 1 other location - About 50 mins to fix
            src/language/LanguageManager.js on lines 954..958

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

                        if (fileNames) {
                            for (i = 0, l = fileNames.length; i < l; i++) {
                                language.addFileName(fileNames[i]);
                            }
                        }
            Severity: Minor
            Found in src/language/LanguageManager.js and 1 other location - About 50 mins to fix
            src/language/LanguageManager.js on lines 948..952

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

                    if (index !== -1) {
                        this._fileNames.splice(index, 1);
            
                        delete _fileNameToLanguageMap[name];
            
            
            Severity: Minor
            Found in src/language/LanguageManager.js and 1 other location - About 40 mins to fix
            src/language/LanguageManager.js on lines 698..704

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

            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 (index !== -1) {
                        this._fileExtensions.splice(index, 1);
            
                        delete _fileExtensionToLanguageMap[extension];
            
            
            Severity: Minor
            Found in src/language/LanguageManager.js and 1 other location - About 40 mins to fix
            src/language/LanguageManager.js on lines 752..758

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

            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

                        pm.definePreference(_NAME_MAP_PREF, "object", {}, {
                            description: Strings.DESCRIPTION_LANGUAGE_FILE_NAMES
                        }).on("change", function () {
                            _updateFromPrefs(_NAME_MAP_PREF);
                        });
            Severity: Minor
            Found in src/language/LanguageManager.js and 1 other location - About 35 mins to fix
            src/language/LanguageManager.js on lines 1177..1181

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

            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

                        pm.definePreference(_EXTENSION_MAP_PREF, "object", {}, {
                            description: Strings.DESCRIPTION_LANGUAGE_FILE_EXTENSIONS
                        }).on("change", function () {
                            _updateFromPrefs(_EXTENSION_MAP_PREF);
                        });
            Severity: Minor
            Found in src/language/LanguageManager.js and 1 other location - About 35 mins to fix
            src/language/LanguageManager.js on lines 1182..1186

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

            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