adobe/brackets

View on GitHub
src/preferences/PreferencesBase.js

Summary

Maintainability
F
6 days
Test Coverage

File PreferencesBase.js has 998 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2013 - 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/preferences/PreferencesBase.js - About 2 days to fix

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

            _addToScopeOrder: function (id, scope, promise, addBefore) {
                var shadowScopeOrder = this._defaults._shadowScopeOrder,
                    shadowEntry,
                    index,
                    isPending = false,
    Severity: Major
    Found in src/preferences/PreferencesBase.js - About 2 hrs to fix

      Function load has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              load: function () {
                  var result = new $.Deferred();
                  var path = this.path;
                  var createIfMissing = this.createIfMissing;
                  var recreateIfInvalid = this.recreateIfInvalid;
      Severity: Major
      Found in src/preferences/PreferencesBase.js - About 2 hrs to fix

        Function set has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                set: function (id, value, options, doNotSave) {
                    options = options || {};
                    var context = this._getContext(options.context),
        
                        // The case where the "default" scope was chosen specifically is special.
        Severity: Minor
        Found in src/preferences/PreferencesBase.js - About 1 hr to fix

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

                  _tryAddToScopeOrder: function (shadowEntry) {
                      var shadowScopeOrder = this._defaults._shadowScopeOrder,
                          index = _.findIndex(shadowScopeOrder, function (entry) {
                              return entry === shadowEntry;
                          }),
          Severity: Minor
          Found in src/preferences/PreferencesBase.js - About 1 hr to fix

            Function PreferencesSystem has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function PreferencesSystem(contextBuilder) {
                    this.contextBuilder = contextBuilder;
            
                    this._knownPrefs = {};
                    this._scopes = {
            Severity: Minor
            Found in src/preferences/PreferencesBase.js - About 1 hr to fix

              Function save has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      save: function () {
                          if (this._saveInProgress) {
                              if (!this._nextSaveDeferred) {
                                  this._nextSaveDeferred = new $.Deferred();
                              }
              Severity: Minor
              Found in src/preferences/PreferencesBase.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                                    if (err) {
                                                        console.log("Cannot move unreadable preferences file " + path + " to trash!!");
                                                    } else {
                                                        console.log("Brackets has recreated the unreadable preferences file " + path + ". You may refer to the deleted file in trash in case you need it!!");
                                                    }
                Severity: Major
                Found in src/preferences/PreferencesBase.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if (pref && pref.type === "object") {
                                                  result = _.extend({}, pref.initial, result);
                                              }
                  Severity: Major
                  Found in src/preferences/PreferencesBase.js - About 45 mins to fix

                    Function set has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            set: function (data, id, value, context, layerID) {
                    Severity: Minor
                    Found in src/preferences/PreferencesBase.js - About 35 mins to fix

                      Function set has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              set: function (data, id, value, context, layerID) {
                      Severity: Minor
                      Found in src/preferences/PreferencesBase.js - About 35 mins to fix

                        Function set has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                set: function (data, id, value, context, layerID) {
                        Severity: Minor
                        Found in src/preferences/PreferencesBase.js - About 35 mins to fix

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

                                  off: function (event, preferenceID, handler) {
                                      if (typeof preferenceID === "function") {
                                          handler = preferenceID;
                                          preferenceID = null;
                                      }
                          Severity: Major
                          Found in src/preferences/PreferencesBase.js and 2 other locations - About 2 hrs to fix
                          src/preferences/PreferencesBase.js on lines 1841..1853
                          src/preferences/PreferencesBase.js on lines 1863..1875

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

                          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

                                  on: function (event, preferenceID, handler) {
                                      if (typeof preferenceID === "function") {
                                          handler = preferenceID;
                                          preferenceID = null;
                                      }
                          Severity: Major
                          Found in src/preferences/PreferencesBase.js and 2 other locations - About 2 hrs to fix
                          src/preferences/PreferencesBase.js on lines 1197..1209
                          src/preferences/PreferencesBase.js on lines 1863..1875

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

                          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

                                  off: function (event, preferenceID, handler) {
                                      if (typeof preferenceID === "function") {
                                          handler = preferenceID;
                                          preferenceID = null;
                                      }
                          Severity: Major
                          Found in src/preferences/PreferencesBase.js and 2 other locations - About 2 hrs to fix
                          src/preferences/PreferencesBase.js on lines 1197..1209
                          src/preferences/PreferencesBase.js on lines 1841..1853

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

                          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

                                                          appshell.fs.moveToTrash(path, function (err) {
                                                              if (err) {
                                                                  console.log("Cannot move unreadable preferences file " + path + " to trash!!");
                                                              } else {
                                                                  console.log("Brackets has recreated the unreadable preferences file " + path + ". You may refer to the deleted file in trash in case you need it!!");
                          Severity: Major
                          Found in src/preferences/PreferencesBase.js and 1 other location - About 2 hrs to fix
                          src/preferences/PreferencesBase.js on lines 210..216

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

                          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

                                                          appshell.fs.moveToTrash(path, function (err) {
                                                              if (err) {
                                                                  console.log("Cannot move unparseable preferences file " + path + " to trash!!");
                                                              } else {
                                                                  console.log("Brackets has recreated the Invalid JSON preferences file " + path + ". You may refer to the deleted file in trash in case you need it!!");
                          Severity: Major
                          Found in src/preferences/PreferencesBase.js and 1 other location - About 2 hrs to fix
                          src/preferences/PreferencesBase.js on lines 184..190

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

                          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

                                      if (!_.isEqual(section[id], value)) {
                                          if (value === undefined) {
                                              delete section[id];
                                          } else {
                                              section[id] = _.cloneDeep(value);
                          Severity: Major
                          Found in src/preferences/PreferencesBase.js and 1 other location - About 1 hr to fix
                          src/preferences/PreferencesBase.js on lines 941..948

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

                          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

                                      if (!_.isEqual(section[id], value)) {
                                          if (value === undefined) {
                                              delete section[id];
                                          } else {
                                              section[id] = _.cloneDeep(value);
                          Severity: Major
                          Found in src/preferences/PreferencesBase.js and 1 other location - About 1 hr to fix
                          src/preferences/PreferencesBase.js on lines 668..675

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

                          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