markdown-note/markdown-notes

View on GitHub
src/browser/notes/note-client.js

Summary

Maintainability
F
3 days
Test Coverage

Function NoteClient has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
Open

var NoteClient = function() {
  var currentlyFocusedNote = null;

  function _init() {
    // Initialize note events with callback events.
Severity: Minor
Found in src/browser/notes/note-client.js - About 1 day 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 NoteClient has 269 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var NoteClient = function() {
  var currentlyFocusedNote = null;

  function _init() {
    // Initialize note events with callback events.
Severity: Major
Found in src/browser/notes/note-client.js - About 1 day to fix

    File note-client.js has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*****************************************************************
     * Acts like a controller and contains code to handle notes in the
     * application. It calls and coordinates the activities of other
     * note-related modules such as the notes, note editor and events.
     *
    Severity: Minor
    Found in src/browser/notes/note-client.js - About 2 hrs to fix

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

        function saveNote(note, isBlur, isNoteComplete) {
          var noteText = note.innerText;
          if (noteText) {
            try {
              var noteID = note.dataset.noteid;
      Severity: Minor
      Found in src/browser/notes/note-client.js - About 1 hr to fix

        Function deleteNote has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function deleteNote(note) {
            try {
              var respConfirm = window.confirm(_i18n.__('note.deletion_confirmation_text'),
                _i18n.__('note.deletion_confirmation_title'));
              if (!respConfirm) {
        Severity: Minor
        Found in src/browser/notes/note-client.js - About 1 hr to fix

          Use path.join() or path.resolve() instead of + to create paths.
          Open

          var _appConfig = require(__dirname + '/../../../config.js');
          Severity: Minor
          Found in src/browser/notes/note-client.js by eslint

          Disallow string concatenation when using __dirname and __filename (no-path-concat)

          In Node.js, the __dirname and __filename global variables contain the directory path and the file path of the currently executing script file, respectively. Sometimes, developers try to use these variables to create paths to other files, such as:

          var fullPath = __dirname + "/foo.js";

          However, there are a few problems with this. First, you can't be sure what type of system the script is running on. Node.js can be run on any computer, including Windows, which uses a different path separator. It's very easy, therefore, to create an invalid path using string concatenation and assuming Unix-style separators. There's also the possibility of having double separators, or otherwise ending up with an invalid path.

          In order to avoid any confusion as to how to create the correct path, Node.js provides the path module. This module uses system-specific information to always return the correct value. So you can rewrite the previous example as:

          var fullPath = path.join(__dirname, "foo.js");

          This example doesn't need to include separators as path.join() will do it in the most appropriate manner. Alternately, you can use path.resolve() to retrieve the fully-qualified path:

          var fullPath = path.resolve(__dirname, "foo.js");

          Both path.join() and path.resolve() are suitable replacements for string concatenation wherever file or directory paths are being created.

          Rule Details

          This rule aims to prevent string concatenation of directory paths in Node.js

          Examples of incorrect code for this rule:

          /*eslint no-path-concat: "error"*/
          
          var fullPath = __dirname + "/foo.js";
          
          var fullPath = __filename + "/foo.js";

          Examples of correct code for this rule:

          /*eslint no-path-concat: "error"*/
          
          var fullPath = dirname + "/foo.js";

          When Not To Use It

          If you want to allow string concatenation of path names. Source: http://eslint.org/docs/rules/

          TODO found
          Open

                  // TODO User tried to move an unsaved note.
          Severity: Minor
          Found in src/browser/notes/note-client.js by fixme

          There are no issues that match your filters.

          Category
          Status