Showing 313 of 321 total issues

File Pager.spec.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Pager from '../Pager'

describe('Pager', () => {
    let pagerFixtureOne
    let pageFixtureTwo
Severity: Minor
Found in src/pager/__tests__/Pager.spec.js - About 2 hrs to fix

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

                systemSettings.all().then(() => {
                    expect(mockApi.get).toHaveBeenCalledTimes(1)
                    expect(mockApi.get.mock.calls[0][0]).toEqual('systemSettings')
                }))
    Severity: Major
    Found in src/system/__tests__/SystemSettings.spec.js and 1 other location - About 2 hrs to fix
    src/system/__tests__/SystemConfiguration.spec.js on lines 149..154

    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

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

                        configuration.all().then(() => {
                            expect(mockApi.get).toHaveBeenCalledTimes(1)
                            expect(mockApi.get.mock.calls[0][0]).toBe(
                                'configuration'
                            )
    Severity: Major
    Found in src/system/__tests__/SystemConfiguration.spec.js and 1 other location - About 2 hrs to fix
    src/system/__tests__/SystemSettings.spec.js on lines 40..43

    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

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

            {
                startDate: `${year}-01-01`,
                endDate: `${year}-06-30`,
                name: `${monthNames[0]} - ${monthNames[5]} ${year}`,
                id: `${year}S1`,
    Severity: Major
    Found in src/period/generators/six-monthly.js and 1 other location - About 1 hr to fix
    src/period/generators/six-monthly.js on lines 22..27

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

    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

            {
                startDate: `${year}-07-01`,
                endDate: `${year}-12-31`,
                name: `${monthNames[6]} - ${monthNames[11]} ${year}`,
                id: `${year}S2`,
    Severity: Major
    Found in src/period/generators/six-monthly.js and 1 other location - About 1 hr to fix
    src/period/generators/six-monthly.js on lines 16..21

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

    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

            it('should return the correct last week for 2015', () => {
                const weeksFor2015 = generateWeeklyPeriodsForYear(2015)
    
                expect(weeksFor2015[weeksFor2015.length - 1]).toEqual({
                    startDate: '2015-12-28',
    Severity: Major
    Found in src/period/generators/__tests__/weekly.spec.js and 1 other location - About 1 hr to fix
    src/period/generators/__tests__/weekly.spec.js on lines 95..104

    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

            it('should return the correct last week for 2017', () => {
                const weeksFor2015 = generateWeeklyPeriodsForYear(2017)
    
                expect(weeksFor2015[weeksFor2015.length - 1]).toEqual({
                    startDate: '2017-12-25',
    Severity: Major
    Found in src/period/generators/__tests__/weekly.spec.js and 1 other location - About 1 hr to fix
    src/period/generators/__tests__/weekly.spec.js on lines 84..93

    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

            it('should not request API if autoload is false', () =>
                dataStore.get('DHIS', false).then((res) => {
                    expect(res).toBeInstanceOf(DataStoreNamespace)
                    expect(apiMock.get).not.toHaveBeenCalled()
                }))
    Severity: Major
    Found in src/datastore/__tests__/DataStore.spec.js and 1 other location - About 1 hr to fix
    src/datastore/__tests__/UserDataStore.spec.js on lines 44..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 71.

    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

            it('should not request API if autoload is false', () =>
                userDataStore.get('DHIS', false).then((res) => {
                    expect(res).toBeInstanceOf(UserDataStoreNamespace)
                    expect(apiMock.get).not.toHaveBeenCalled()
                }))
    Severity: Major
    Found in src/datastore/__tests__/UserDataStore.spec.js and 1 other location - About 1 hr to fix
    src/datastore/__tests__/DataStore.spec.js on lines 44..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 71.

    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

                it('should pass only the properties that are owned to the api', () => {
                    const expectedPayload = fixtures.get('/singleUserOwnerFields')
    
                    userModelDefinition.saveNew(model)
    
    
    Severity: Major
    Found in src/model/__tests__/ModelDefinition.spec.js and 1 other location - About 1 hr to fix
    src/model/__tests__/ModelDefinition.spec.js on lines 1216..1222

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

    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

                it('should pass only the properties that are owned to the api', () => {
                    const expectedPayload = fixtures.get('/singleUserOwnerFields')
    
                    userModelDefinition.save(model)
    
    
    Severity: Major
    Found in src/model/__tests__/ModelDefinition.spec.js and 1 other location - About 1 hr to fix
    src/model/__tests__/ModelDefinition.spec.js on lines 1337..1343

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

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

        extractMetadata() {
            const metaData = { ...this.response.metaData }
    
            const { dimensions, items } = metaData
    
    
    Severity: Minor
    Found in src/analytics/AnalyticsResponse.js - About 1 hr to fix

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

                  return i18n.load().then(() => {
                      expect(apiGet).toHaveBeenCalledTimes(0)
                      expect(apiPost).toHaveBeenCalledTimes(0)
                      expect(apiReq).toHaveBeenCalledTimes(1)
                  })
      Severity: Major
      Found in src/i18n/__tests__/I18n.spec.js and 1 other location - About 1 hr to fix
      src/i18n/__tests__/I18n.spec.js on lines 206..210

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

      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

                  it('should return the correct feedback recipient user group', () => {
                      expect.assertions(1)
      
                      return configuration.get('feedbackRecipients').then((res) => {
                          expect(res).toBe(mockConfiguration.feedbackRecipients)
      Severity: Major
      Found in src/system/__tests__/SystemConfiguration.spec.js and 1 other location - About 1 hr to fix
      src/system/__tests__/SystemConfiguration.spec.js on lines 181..187

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

      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

                  return i18n.load().then(() => {
                      expect(apiGet).toHaveBeenCalledTimes(0)
                      expect(apiPost).toHaveBeenCalledTimes(0)
                      expect(apiReq).toHaveBeenCalledTimes(3)
                  })
      Severity: Major
      Found in src/i18n/__tests__/I18n.spec.js and 1 other location - About 1 hr to fix
      src/i18n/__tests__/I18n.spec.js on lines 186..190

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

      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

                  it('should return the correct systemId', () => {
                      expect.assertions(1)
      
                      return configuration.get('systemId').then((res) => {
                          expect(res).toBe(mockConfiguration.systemId)
      Severity: Major
      Found in src/system/__tests__/SystemConfiguration.spec.js and 1 other location - About 1 hr to fix
      src/system/__tests__/SystemConfiguration.spec.js on lines 189..195

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

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

          create(data) {
              const model = Model.create(this)
              const models = ModelDefinitions.getModelDefinitions()
              const dataValues = data
                  ? Object.assign({}, data)
      Severity: Minor
      Found in src/model/ModelDefinition.js - About 1 hr to fix

        Function weeklyMatcherParser has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const weeklyMatcherParser = (match, locale = 'en') => {
            const year = parseInt(match[1], 10)
            const weekType = match[2]
            const week = parseInt(match[3], 10)
        
        
        Severity: Minor
        Found in src/period/parser.js - About 1 hr to fix

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

                  it('Updates the dirty flag', () => {
                      expect(mcp.dirty).toBe(false)
                      mcp.add(testModels[0])
                      expect(mcp.dirty).toBe(true)
                  })
          Severity: Major
          Found in src/model/__tests__/ModelCollectionProperty.spec.js and 1 other location - About 1 hr to fix
          src/model/__tests__/ModelCollectionProperty.spec.js on lines 130..134

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

          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

                  it('Updates the dirty flag', () => {
                      expect(mcp.dirty).toBe(false)
                      mcp.remove(testModels[0])
                      expect(mcp.dirty).toBe(true)
                  })
          Severity: Major
          Found in src/model/__tests__/ModelCollectionProperty.spec.js and 1 other location - About 1 hr to fix
          src/model/__tests__/ModelCollectionProperty.spec.js on lines 86..90

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

          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