kumabook/stickynotes

View on GitHub

Showing 28 of 74 total issues

File background.js has 580 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global setTimeout: false, clearTimeout: false */
/* eslint no-use-before-define: ["error", { "functions": false }] */
import browser from 'webextension-polyfill';
import idb     from './utils/indexedDB';
import logger  from './utils/logger';
Severity: Major
Found in src/background.js - About 1 day to fix

    File StickyView.js has 458 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import browser from 'webextension-polyfill';
    import ColorPicker from './ColorPicker';
    import TagEditor from './TagEditor';
    import Dialog from './Dialog';
    import StickyMenu from './StickyMenu';
    Severity: Minor
    Found in src/content_scripts/StickyView.js - About 7 hrs to fix

      Function handleContentScriptMessage has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function handleContentScriptMessage(msg) {
        logger.info(`handleContentScriptMessage ${JSON.stringify(msg)}`);
        const port = getPort(msg.portName);
        switch (msg.type) {
          case 'load-options': {
      Severity: Major
      Found in src/background.js - About 3 hrs to fix

        Function handlePopupMessage has 84 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function handlePopupMessage(msg) {
          logger.info(`handlePopupMessage ${msg.type} from ${msg.portName}`);
          const port = getPort(msg.portName);
          switch (msg.type) {
            case 'list-menu': {
        Severity: Major
        Found in src/background.js - About 3 hrs to fix

          Function messageListener has 78 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function messageListener(msg) {
            const { type } = msg;
            switch (type) {
              case 'load-stickies':
                loadStickies(msg.stickies, msg.targetUrl);
          Severity: Major
          Found in src/content_script.js - About 3 hrs to fix

            File StickyList.jsx has 282 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React from 'react';
            import PropTypes from 'prop-types';
            import { connect } from 'react-redux';
            import { withRouter } from 'react-router-dom';
            import TreeView from 'react-treeview';
            Severity: Minor
            Found in src/containers/StickyList.jsx - About 2 hrs to fix

              Function importStickies has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function importStickies(stickies, db) {
                const createdStickies = [];
                const updatedStickies = [];
                return stickies.reduce((p, s) => {
                  s = Sticky.normalize(s);
              Severity: Major
              Found in src/background.js - About 2 hrs to fix

                Function render has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  render() {
                    return (
                      <div className="container">
                        <div className="navBar">
                          <button
                Severity: Minor
                Found in src/containers/Login.jsx - About 2 hrs to fix

                  Function render has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    render() {
                      return (
                        <div className="container">
                          <div className="navBar">
                            <button
                  Severity: Minor
                  Found in src/containers/SignUp.jsx - About 1 hr to fix

                    Function messageListener has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function messageListener(msg) {
                      const { type } = msg;
                      switch (type) {
                        case 'load-stickies':
                          loadStickies(msg.stickies, msg.targetUrl);
                    Severity: Minor
                    Found in src/content_script.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 setupContextMenus has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function setupContextMenus() {
                      browser.contextMenus.create({
                        id:       'create-sticky',
                        title:    'create sticky',
                        contexts: ['all'],
                    Severity: Minor
                    Found in src/background.js - About 1 hr to fix

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

                      function handleSidebarMessage(msg) {
                        const port = getPort(msg.portName);
                        switch (msg.type) {
                          case 'fetch-stickies': {
                            idb.open(dbName).then(db => Promise.all([
                      Severity: Minor
                      Found in src/background.js - About 1 hr to fix

                        Function drag has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        StickyView.prototype.drag = function drag(e) {
                          const c      = StickyView.classes;
                          const pos    = this.getElementPosition(this.dom);
                          const right  = pos.left + parseInt(this.dom.style.width, 10);
                          const bottom = pos.top + parseInt(this.dom.style.height, 10);
                        Severity: Minor
                        Found in src/content_scripts/StickyView.js - About 1 hr to fix

                          Function splitToNames has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                          TagEditor.prototype.splitToNames = function splitToNames(str) {
                            /* eslint-disable no-irregular-whitespace  */
                            const tagsStr = `${str},`.replace(/^[\s ]+|[\s ]+$/g, '');
                            const tags     = [];
                            let tagList      = (tagsStr).split(',');
                          Severity: Minor
                          Found in src/content_scripts/TagEditor.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 handleOptionsUIMessage has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function handleOptionsUIMessage(msg) {
                            const port = getPort(msg.portName);
                            switch (msg.type) {
                              case 'import': {
                                const stickies = msg.payload;
                          Severity: Minor
                          Found in src/background.js - About 1 hr to fix

                            Function render has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              render() {
                                const groupByOptions = Object.keys(GroupBy).map((key) => {
                                  const value = GroupBy[key];
                                  return (
                                    <option
                            Severity: Minor
                            Found in src/containers/StickyList.jsx - About 1 hr to fix

                              Function sendRequest has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function sendRequest(method, url, params) {
                                /* eslint-disable prefer-promise-reject-errors */
                                return getAccessToken().then((accessToken) => {
                                  const headers = new Headers();
                                  headers.append('Accept', 'application/json');
                              Severity: Minor
                              Found in src/utils/api.js - About 1 hr to fix

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

                                StickyView.prototype.showMenu = function showMenu() {
                                  const c = StickyView.classes;
                                  this.hideDialog();
                                  this.dialog = new Dialog({ className: c.MENU_DIALOG });
                                  this.dialog.push(new StickyMenu({
                                Severity: Minor
                                Found in src/content_scripts/StickyView.js - About 1 hr to fix

                                  Function addStickyView has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function addStickyView(sticky) {
                                    const stickyView = new StickyView({
                                      sticky,
                                      onClickDeleteButton:   () => setTimeout(() => deleteSticky(sticky), 0),
                                      onClickMinimizeButton: () => stickyView.minimize(),
                                  Severity: Minor
                                  Found in src/content_script.js - About 1 hr to fix

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

                                    function* watchPort() {
                                      const portChannel = yield call(createPortChannel, port);
                                    
                                      for (;;) {
                                        const event = yield take(portChannel);
                                    Severity: Minor
                                    Found in src/sagas/sidebar.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language