mrgodhani/raven-reader

View on GitHub
src/background.js

Summary

Maintainability
F
3 days
Test Coverage

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

'use strict'

import { app, protocol, BrowserWindow, globalShortcut, nativeTheme, ipcMain, dialog, Notification, shell, powerMonitor, session } from 'electron'
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
Severity: Major
Found in src/background.js - About 1 day to fix

    Function createWindow has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function createWindow () {
      // Create the browser window.
      win = new BrowserWindow({
        minWidth: 1280,
        minHeight: 720,
    Severity: Major
    Found in src/background.js - About 2 hrs to fix

      Function createWindow has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      async function createWindow () {
        // Create the browser window.
        win = new BrowserWindow({
          minWidth: 1280,
          minHeight: 720,
      Severity: Minor
      Found in src/background.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 handleInoreader has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function handleInoreader (url) {
        if (url.includes('ravenreader://inoreader/auth')) {
          const q = new URL(url).searchParams
          if (q.has('code')) {
            axios.post('https://www.inoreader.com/oauth2/token', {
      Severity: Minor
      Found in src/background.js - About 1 hr to fix

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

        function signInPocketWithPopUp () {
          if (os.platform() === 'darwin') {
            consumerKey = process.env.VUE_APP_POCKET_MAC_KEY
          }
        
        
        Severity: Minor
        Found in src/background.js - About 1 hr to fix

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

          ipcMain.handle('feedbin-login', async (event, data) => {
            const result = await axios.get(data.endpoint, {
              auth: {
                username: data.creds.email,
                password: data.creds.password
          Severity: Major
          Found in src/background.js and 1 other location - About 2 hrs to fix
          src/background.js on lines 617..625

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

          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

          ipcMain.handle('feedbin-endpoint-fetch', async (event, data) => {
            const result = await axios.get(data.endpoint, {
              auth: {
                username: data.creds.email,
                password: data.creds.password
          Severity: Major
          Found in src/background.js and 1 other location - About 2 hrs to fix
          src/background.js on lines 607..615

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

          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

            axios
              .post(
                'https://getpocket.com/v3/oauth/request', {
                  consumer_key: consumerKey,
                  redirect_uri: 'http://127.0.0.1'
          Severity: Minor
          Found in src/background.js and 1 other location - About 40 mins to fix
          src/main/pocket.js on lines 87..105

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

          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

              axios
                .post(
                  'https://getpocket.com/v3/oauth/authorize', {
                    consumer_key: consumerKey,
                    code: code
          Severity: Minor
          Found in src/background.js and 1 other location - About 40 mins to fix
          src/main/pocket.js on lines 31..48

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

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

            if (store.has('fever_creds')) {
              state.fever_connected = true
              state.fever = store.get('fever_creds')
            }
          Severity: Major
          Found in src/background.js and 4 other locations - About 30 mins to fix
          src/background.js on lines 394..397
          src/background.js on lines 401..404
          src/background.js on lines 405..408
          src/background.js on lines 413..416

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

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

            if (store.has('pocket_creds')) {
              state.pocket_connected = true
              state.pocket = store.get('pocket_creds')
            }
          Severity: Major
          Found in src/background.js and 4 other locations - About 30 mins to fix
          src/background.js on lines 394..397
          src/background.js on lines 405..408
          src/background.js on lines 409..412
          src/background.js on lines 413..416

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

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

            if (store.has('inoreader_creds')) {
              state.inoreader_connected = true
              state.inoreader = store.get('inoreader_creds')
            }
          Severity: Major
          Found in src/background.js and 4 other locations - About 30 mins to fix
          src/background.js on lines 401..404
          src/background.js on lines 405..408
          src/background.js on lines 409..412
          src/background.js on lines 413..416

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

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

            if (store.has('instapaper_creds')) {
              state.instapaper_connected = true
              state.instapaper = store.get('instapaper_creds')
            }
          Severity: Major
          Found in src/background.js and 4 other locations - About 30 mins to fix
          src/background.js on lines 394..397
          src/background.js on lines 401..404
          src/background.js on lines 409..412
          src/background.js on lines 413..416

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

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

            if (store.has('selfhost_creds')) {
              state.selfhost_connected = true
              state.selfhost = store.get('selfhost_creds')
            }
          Severity: Major
          Found in src/background.js and 4 other locations - About 30 mins to fix
          src/background.js on lines 394..397
          src/background.js on lines 401..404
          src/background.js on lines 405..408
          src/background.js on lines 409..412

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

          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