mrgodhani/raven-reader

View on GitHub

Showing 64 of 64 total issues

Function createMenu has 263 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function createMenu (mainWindow) {
  // Create the Application's main menu
  const template = [{
    label: 'Edit',
    submenu: [{
Severity: Major
Found in src/main/menu.js - About 1 day to fix

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

      UPDATE_ARTICLE_CATEGORY (state, data) {
        const articles = state.articles.filter(item => item.category === data.old.title)
        for (let i = 0; i < articles.length; i++) {
          const index = state.articles.findIndex(item => item._id === articles[i]._id)
          db.updateArticleCategory(state.articles[index]._id, data.new.title)
    Severity: Major
    Found in src/renderer/store/modules/Article.js and 1 other location - About 6 hrs to fix
    src/renderer/store/modules/Feed.js on lines 34..41

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

    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

      UPDATE_FEED_CATEGORY (state, data) {
        const feeds = state.feeds.filter(item => item.category === data.old.title)
        for (let i = 0; i < feeds.length; i++) {
          const index = state.feeds.findIndex(item => item._id === feeds[i]._id)
          db.updateFeedCategory(state.feeds[index].id, data.new.title)
    Severity: Major
    Found in src/renderer/store/modules/Feed.js and 1 other location - About 6 hrs to fix
    src/renderer/store/modules/Article.js on lines 192..199

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

    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

      markUnread (id, podcast) {
        if (podcast) {
          article.update({
            _id: id
          }, {
    Severity: Major
    Found in src/renderer/services/db.js and 1 other location - About 4 hrs to fix
    src/renderer/services/db.js on lines 185..208

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

    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

      markRead (id, podcast) {
        if (podcast) {
          article.update({
            _id: id
          }, {
    Severity: Major
    Found in src/renderer/services/db.js and 1 other location - About 4 hrs to fix
    src/renderer/services/db.js on lines 209..232

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

    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

    File Article.js has 311 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import db from '../../services/db'
    import helper from '../../services/helpers'
    import dayjs from 'dayjs'
    import relativeTime from 'dayjs/plugin/relativeTime'
    import truncate from 'lodash.truncate'
    Severity: Minor
    Found in src/renderer/store/modules/Article.js - About 3 hrs to fix

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

        DELETE_ARTICLES_CATEGORY (state, category) {
          const articles = state.articles.filter(item => item.title === category)
          articles.forEach(async (article) => {
            await cacheService.uncache(`raven-${article._id}`)
          })
      Severity: Major
      Found in src/renderer/store/modules/Article.js and 1 other location - About 3 hrs to fix
      src/renderer/store/modules/Article.js on lines 142..148

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

      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

        DELETE_ARTICLES (state, id) {
          const articles = state.articles.filter(item => item.feed_id === id)
          articles.forEach(async (article) => {
            await cacheService.uncache(`raven-${article._id}`)
          })
      Severity: Major
      Found in src/renderer/store/modules/Article.js and 1 other location - About 3 hrs to fix
      src/renderer/store/modules/Article.js on lines 135..141

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

      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

      Function subscribe has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        subscribe (feeds, category = null, faviconData = null, refresh = false, importData = false) {
          const task = (task, category, refresh) => {
            const posts = []
            if (!refresh) {
              task.feed.meta.favicon = task.favicon
      Severity: Major
      Found in src/renderer/services/helpers.js - About 2 hrs to fix

        `` has 25 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default {
          ensureIndex (db, field) {
            db.ensureIndex({ fieldName: field, unique: true }, (err) => {
              if (err) {}
            })
        Severity: Minor
        Found in src/renderer/services/db.js - About 2 hrs to fix

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

          function createWindow () {
            /**
             * If there is already data in old directory. Moved it to new
             */
            const oldDirectory = jetpack.cwd(app.getPath('userData'))
          Severity: Major
          Found in src/main/index.js - About 2 hrs to fix

            File menu.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { app, Menu } from 'electron'
            var articleSelected = false
            
            export default function createMenu (mainWindow) {
              // Create the Application's main menu
            Severity: Minor
            Found in src/main/menu.js - About 2 hrs to fix

              actions has 21 functions (exceeds 20 allowed). Consider refactoring.
              Open

              const actions = {
                loadArticles ({ commit }) {
                  db.fetchArticles(docs => {
                    commit('LOAD_ARTICLES', docs)
                  })
              Severity: Minor
              Found in src/renderer/store/modules/Article.js - About 2 hrs to fix

                mutations has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                const mutations = {
                  LOAD_ARTICLES (state, articles) {
                    state.articles = articles.map((item) => {
                      item.feed_title = truncate(item.feed_title, { length: 20 })
                      item.title = truncate(item.title, { length: 250 })
                Severity: Minor
                Found in src/renderer/store/modules/Article.js - About 2 hrs to fix

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

                    updateArticleCategory (id, category) {
                      article.update({
                        _id: id
                      }, {
                        $set: {
                  Severity: Major
                  Found in src/renderer/services/db.js and 1 other location - About 1 hr to fix
                  src/renderer/services/db.js on lines 86..100

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

                  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

                    updateFeedCategory (id, category) {
                      feed.update({
                        id: id
                      }, {
                        $set: {
                  Severity: Major
                  Found in src/renderer/services/db.js and 1 other location - About 1 hr to fix
                  src/renderer/services/db.js on lines 131..145

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

                  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

                      if (data.type === 'UNREAD') {
                        state.articles[index].read = false
                        if (state.articles[index].podcast) {
                          state.articles[index].played = false
                        }
                  Severity: Major
                  Found in src/renderer/store/modules/Article.js and 1 other location - About 1 hr to fix
                  src/renderer/store/modules/Article.js on lines 107..112

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

                  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

                      if (data.type === 'READ') {
                        state.articles[index].read = true
                        if (state.articles[index].podcast) {
                          state.articles[index].played = true
                        }
                  Severity: Major
                  Found in src/renderer/store/modules/Article.js and 1 other location - About 1 hr to fix
                  src/renderer/store/modules/Article.js on lines 114..119

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

                  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

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

                  function createWindow () {
                    /**
                     * If there is already data in old directory. Moved it to new
                     */
                    const oldDirectory = jetpack.cwd(app.getPath('userData'))
                  Severity: Minor
                  Found in src/main/index.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 sortBy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const sortBy = (key, pref) => {
                    if (pref === 'asc') {
                      return (a, b) => (a[key] > b[key]) ? 1 : ((b[key] > a[key]) ? -1 : 0)
                    }
                      return (a, b) => (a[key] < b[key]) ? 1 : ((b[key] < a[key]) ? -1 : 0)
                  Severity: Minor
                  Found in src/renderer/store/modules/Article.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

                  Severity
                  Category
                  Status
                  Source
                  Language