Showing 90 of 251 total issues

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

export const Sidebar = ({
  snippets,
  filterText,
  filterTags,
  filterLanguage,
Severity: Minor
Found in src/components/layout/sidebar/Sidebar.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 createWindow has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createWindow = () => {
  log.transports.file.level = 'debug';
  autoUpdater.logger = log;
  autoUpdater.checkForUpdatesAndNotify();

Severity: Major
Found in src/electron/main.js - About 2 hrs to fix

    File snippets.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {
      merge,
      keyBy,
      update,
      set,
    Severity: Minor
    Found in src/reducers/snippets.js - About 2 hrs to fix

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

        render() {
          const { data } = this.props;
      
          const menu = (
            <React.Fragment>
      Severity: Major
      Found in docs/src/components/header.js - About 2 hrs to fix

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

          render() {
            const { file, username, snippetId, edit, toggleCollapse, theme } = this.props;
            const openOnWebUrl = `${getSnippetUrl('/gist')}/${username}/${snippetId}#file-${file.filename}`;
        
            return (
        Severity: Minor
        Found in src/components/layout/content/snippet/SnippetHeader.js - About 2 hrs to fix

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

          export const responseHandler = (error, result, dispatch, action) => {
            if (error) {
              if (error.response && error.response.headers['x-github-otp']) {
                setNotification({
                  title: 'Two factor authentication',
          Severity: Minor
          Found in src/middlewares/responseHandler.js - About 2 hrs to fix

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

            export const snippets = (state = initialState, action) => {
              switch (action.type) {
                case AT.GET_SNIPPETS.SUCCESS: {
                  const lastUpdated = state.lastUpdated === null ? toISOString() : state.lastUpdated;
            
            
            Severity: Minor
            Found in src/reducers/snippets.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 render has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              render() {
                const {
                  snippets,
                  filterText,
                  filterTags,
            Severity: Minor
            Found in src/components/layout/SuperSearch.js - About 1 hr to fix

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

                render() {
                  const { comments, showComments, snippetId, deleteComment, theme } = this.props;
              
                  return (
                    <CommentsWrapper show={ showComments }>
              Severity: Minor
              Found in src/components/layout/content/snippet/Comments.js - About 1 hr to fix

                Function handleMacOSUpdates has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function handleMacOSUpdates(mainWindow) {
                  if (isMacOS) {
                    const LATEST_RELEASED_VERSION_URL = 'https://api.github.com/repos/Gisto/Gisto/releases/latest';
                    const request = require('superagent');
                    const semver = require('semver');
                Severity: Minor
                Found in src/electron/main/helpers.js - About 1 hr to fix

                  Function searchType has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    const searchType = () => {
                      if (!isEmpty(trim(filterText))) {
                        return isTag(filterText) ? 'free text tag' : 'free text';
                      }
                  
                  
                  Severity: Minor
                  Found in src/components/layout/sidebar/Sidebar.js - About 1 hr to fix

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

                    function updateChecker(mainWindow) {
                      ipcMain.on('downloadUpdate', () => autoUpdater.downloadUpdate());
                      ipcMain.on('quitAndInstall', () => autoUpdater.quitAndInstall(true, true));
                    
                      autoUpdater.logger = log;
                    Severity: Minor
                    Found in src/electron/main/helpers.js - About 1 hr to fix

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

                      export const prepareFilesForUpdate = (snippet: ISnippet) => {
                        const cleanFiles = flow([
                          map((file) => {
                            return pick(['filename', 'content', 'originalFileName', 'delete', 'isNew'], file);
                          }),
                      Severity: Minor
                      Found in src/utils/snippets.ts - About 1 hr to fix

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

                          render() {
                            const { snippet, edit, tempSnippet, showComments, addTempFile } = this.props;
                            const currentSnippet = edit ? tempSnippet : snippet;
                            const files = filter((file) => !file.delete, get('files', currentSnippet));
                        
                        
                        Severity: Minor
                        Found in src/components/layout/content/Snippet.js - About 1 hr to fix

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

                            componentDidMount() {
                              if (!sessionStorage.getItem('gistoReleases')) {
                                fetch('https://api.github.com/repos/Gisto/Gisto/releases/latest')
                                  .then((response) => response.json())
                                  .then((data) => {
                          Severity: Minor
                          Found in docs/src/components/Downloads.js - About 1 hr to fix

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

                            function handleDownload(win) {
                              win.webContents.session.on('will-download', (event, item, sender) => {
                                const isUpdateUrl = includes(
                                  ['https://github.com/Gisto/Gisto/releases/download/'],
                                  head(item.getURLChain())
                            Severity: Minor
                            Found in src/electron/main/helpers.js - About 1 hr to fix

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

                                render() {
                                  const { lightText, colorDanger } = this.props.theme;
                                  const {
                                    children,
                                    size = 22,
                              Severity: Minor
                              Found in src/components/common/UtilityIcon.js - About 1 hr to fix

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

                                  render() {
                                    return (
                                      <Wrapper>
                                        <img src={ logoImg } width="80" alt=""/>
                                        <h2>About Gisto</h2>
                                Severity: Minor
                                Found in src/components/layout/content/About.js - About 1 hr to fix

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

                                  const filterByFreeText = (snippets: ISnippet, filterText: string) => {
                                    try {
                                      new RegExp(filterText, 'gi');
                                    } catch (e) {
                                      return false;
                                  Severity: Minor
                                  Found in src/utils/snippets.ts - About 1 hr to fix

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

                                      render() {
                                        const { snippet, theme } = this.props;
                                    
                                        return (
                                          <Router>
                                    Severity: Minor
                                    Found in src/components/layout/sidebar/Snippet.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language