prescottprue/fireadmin

View on GitHub
functions/src/actionRunner/actionRunner.spec.ts

Summary

Maintainability
F
2 wks
Test Coverage

File actionRunner.spec.ts has 784 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import 'mocha'
import * as admin from 'firebase-admin'
import fs from 'fs'
import { expect } from 'chai'
import * as sinon from 'sinon'
Severity: Major
Found in functions/src/actionRunner/actionRunner.spec.ts - About 1 day to fix

    Function createValidActionRunnerStubs has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function createValidActionRunnerStubs(opts?: any) {
          const {
            projectId = 'asdfasdf1',
            srcResource = 'rtdb',
            destResource = 'rtdb',
    Severity: Major
    Found in functions/src/actionRunner/actionRunner.spec.ts - About 2 hrs to fix

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

          it('Throws if environment does not an environment key or id', async () => {
            const snap = {
              val: () => ({
                projectId: 'test',
                inputValues: [],
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 1 other location - About 1 day to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 402..437

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

      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('Throws if environment does not have databaseURL', async () => {
            const snap = {
              val: () => ({
                projectId: 'test',
                inputValues: [],
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 1 other location - About 1 day to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 439..476

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

      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('Throws if action template does not contain inputValues', async () => {
            const snap = {
              val: () => ({ projectId: 'test', template: { steps: [], inputs: [] } }),
              ref: refStub()
            }
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 1 other location - About 1 day to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 368..400

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

      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('Throws if inputValues are not passed', async () => {
            const snap = {
              val: () => ({
                projectId: 'test',
                template: { steps: [], inputs: [] }
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 1 other location - About 1 day to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 337..366

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

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

          describe('with src: "storage" and dest: "rtdb"', () => {
            it('successfully copies from Cloud Storage to RTDB', async () => {
              const { snapStub } = createValidActionRunnerStubs({
                srcResource: 'storage',
                destResource: 'rtdb'
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 2 other locations - About 1 day to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 761..788
      functions/src/actionRunner/actionRunner.spec.ts on lines 816..843

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

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

          describe('with src: "firestore" and dest: "rtdb"', () => {
            it('successfully copies from Firestore to Real Time Database', async () => {
              const { snapStub } = createValidActionRunnerStubs({
                srcResource: 'firestore',
                destResource: 'rtdb'
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 2 other locations - About 1 day to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 816..843
      functions/src/actionRunner/actionRunner.spec.ts on lines 875..902

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

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

          describe('with src: "rtdb" and dest: "firestore"', () => {
            it('successfully copies from RTDB to Firestore', async () => {
              const { snapStub } = createValidActionRunnerStubs({
                srcResource: 'rtdb',
                destResource: 'firestore'
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 2 other locations - About 1 day to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 761..788
      functions/src/actionRunner/actionRunner.spec.ts on lines 875..902

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

      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

              firestore: {
                batch: sinon.stub().returns({
                  commit: sinon.stub().returns(Promise.resolve()),
                  set: sinon.stub().returns({})
                }),
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 1 other location - About 5 hrs to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 55..68

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

      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

              firestore: {
                batch: sinon.stub().returns({
                  commit: sinon.stub().returns(Promise.resolve()),
                  set: sinon.stub().returns({})
                }),
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 1 other location - About 5 hrs to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 77..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 144.

      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

            docStub.withArgs(`projects/${validProjectId}/environments/asdf`).returns({
              get: sinon.stub().returns(
                Promise.resolve({
                  data: () => ({
                    serviceAccount: {
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 1 other location - About 5 hrs to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 643..668

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

      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

            const environmentDocStub = docStub
              .withArgs(`projects/${projectId}/environments/asdf`)
              .returns({
                get: sinon.stub().returns(
                  Promise.resolve({
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 1 other location - About 5 hrs to fix
      functions/src/actionRunner/actionRunner.spec.ts on lines 558..581

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

      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

              file: sinon.stub().returns({
                delete: sinon.stub().returns(Promise.resolve({})),
                // Mock download method with invalid JSON file data
                download: sinon.spy(({ destination }) => {
                  fs.writeFileSync(
      Severity: Major
      Found in functions/src/actionRunner/actionRunner.spec.ts and 1 other location - About 4 hrs to fix
      functions/src/copyServiceAccountToFirestore/copyServiceAccountToFirestore.spec.ts on lines 37..47

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

      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