ICIJ/datashare-client

View on GitHub

Showing 53 of 55 total issues

File search.js has 508 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  castArray,
  concat,
  cloneDeep,
  each,
Severity: Major
Found in src/store/modules/search.js - About 1 day to fix

    Function actionBuilder has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

    function actionBuilder(api) {
      return {
        async get({ commit, state }, idAndRouting) {
          try {
            const { id, index, routing } = idAndRouting
    Severity: Minor
    Found in src/store/modules/document.js - About 7 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 actionBuilder has 160 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function actionBuilder(api) {
      return {
        async get({ commit, state }, idAndRouting) {
          try {
            const { id, index, routing } = idAndRouting
    Severity: Major
    Found in src/store/modules/document.js - About 6 hrs to fix

      Function actionsBuilder has 141 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function actionsBuilder(api) {
        return {
          async refresh({ state, commit, getters }, updateIsReady = true) {
            commit('isReady', !updateIsReady)
            commit('error', null)
      Severity: Major
      Found in src/store/modules/search.js - About 5 hrs to fix

        Function actionsBuilder has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        function actionsBuilder(api) {
          return {
            async refresh({ state, commit, getters }, updateIsReady = true) {
              commit('isReady', !updateIsReady)
              commit('error', null)
        Severity: Minor
        Found in src/store/modules/search.js - About 5 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 actionBuilder has 128 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function actionBuilder(api) {
          return {
            clearBatchSearchResults({ commit }) {
              commit(CLEAR_BATCH_SEARCH_RESULTS)
            },
        Severity: Major
        Found in src/store/modules/batchSearch.js - About 5 hrs to fix

          File document.js has 309 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { compact, concat, findIndex, flattenDeep, get, keys, map, sortBy, sumBy, uniqBy, values } from 'lodash'
          import Vue from 'vue'
          
          import EsDocList from '@/api/resources/EsDocList'
          
          
          Severity: Minor
          Found in src/store/modules/document.js - About 3 hrs to fix

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

              parentDocument(state, raw) {
                if (raw !== null) {
                  Vue.set(state, 'parentDocument', EsDocList.instantiate(raw))
                  state.doc.parent = raw
                } else {
            Severity: Major
            Found in src/store/modules/document.js and 1 other location - About 2 hrs to fix
            src/store/modules/document.js on lines 107..115

            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

              rootDocument(state, raw) {
                if (raw !== null) {
                  Vue.set(state, 'rootDocument', EsDocList.instantiate(raw))
                  state.doc.root = raw
                } else {
            Severity: Major
            Found in src/store/modules/document.js and 1 other location - About 2 hrs to fix
            src/store/modules/document.js on lines 98..106

            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

              static getIntervalOption(interval = this.interval) {
                switch (interval) {
                  case 'day':
                    return { interval: '1d', format: 'yyyy-MM-dd', missing: '1970-01-01' }
                  case 'month':
            Severity: Major
            Found in src/store/filters/FilterDateRange.js and 1 other location - About 2 hrs to fix
            src/store/filters/FilterDate.js on lines 47..56

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

            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

              static getIntervalOption(interval = 'month') {
                switch (interval) {
                  case 'day':
                    return { interval: '1d', format: 'yyyy-MM-dd', missing: '1970-01-01' }
                  case 'month':
            Severity: Major
            Found in src/store/filters/FilterDate.js and 1 other location - About 2 hrs to fix
            src/store/filters/FilterDateRange.js on lines 42..51

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

            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 actionsBuilder has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function actionsBuilder(api) {
              return {
                submitExtract({ state }) {
                  if (state.form.path) {
                    return api.indexPath(state.form.path, state.form)
            Severity: Minor
            Found in src/store/modules/indexing.js - About 1 hr to fix

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

              const ProjectsMixin = (superclass) =>
                class extends superclass {
                  /**
                   * Call a function when a project is selected
                   * @param {String} name - Name of the project
              Severity: Minor
              Found in src/core/ProjectsMixin.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

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

                  } else {
                    return body.query('has_parent', { parent_type: 'Document' }, (q) => {
                      return q.query('has_child', 'type', 'NamedEntity', {}, (r) => {
                        return r.query('terms', 'mentionNorm', param.values)
                      })
              Severity: Major
              Found in src/store/filters/FilterNamedEntity.js and 1 other location - About 1 hr to fix
              src/store/filters/FilterNamedEntity.js on lines 70..76

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

              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

                addParentExcludeFilter(body, param) {
                  return body.query('has_parent', { parent_type: 'Document' }, (q) => {
                    return q.notQuery('has_child', 'type', 'NamedEntity', {}, (r) => {
                      return r.query('terms', 'mentionNorm', param.values)
                    })
              Severity: Major
              Found in src/store/filters/FilterNamedEntity.js and 1 other location - About 1 hr to fix
              src/store/filters/FilterNamedEntity.js on lines 61..67

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

              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 retrieveQueryTerms has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                retrieveQueryTerms(state) {
                  let terms = []
                  function getTerm(query, path, start, operator, isFuzzyNumber = false) {
                    const term = get(query, join([path, 'term'], '.'), '')
                    const field = get(query, join([path, 'field'], '.'), '')
              Severity: Minor
              Found in src/store/modules/search.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 actionsBuilder has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function actionsBuilder(api) {
                return {
                  async starDocuments({ commit }, documents = []) {
                    const starDocs = prepareDocumentIds(documents).map(function ({ index, documentIds }) {
                      return api.starDocuments(index, documentIds)
              Severity: Minor
              Found in src/store/modules/starred.js - About 1 hr to fix

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

                  retrieveQueryTerms(state) {
                    let terms = []
                    function getTerm(query, path, start, operator, isFuzzyNumber = false) {
                      const term = get(query, join([path, 'term'], '.'), '')
                      const field = get(query, join([path, 'field'], '.'), '')
                Severity: Minor
                Found in src/store/modules/search.js - About 1 hr to fix

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

                    unregister(state, name) {
                      const index = findIndex(state.registered, { name })
                      if (index > -1) {
                        state.registered.splice(index, 1)
                      }
                  Severity: Major
                  Found in src/store/modules/pipelines.js and 1 other location - About 1 hr to fix
                  src/store/modules/hooks.js on lines 34..39

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

                  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

                    unregister(state, name) {
                      const index = findIndex(state.registered, { name })
                      if (index > -1) {
                        state.registered.splice(index, 1)
                      }
                  Severity: Major
                  Found in src/store/modules/hooks.js and 1 other location - About 1 hr to fix
                  src/store/modules/pipelines.js on lines 93..98

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language