Bernd-L/exDateMan

View on GitHub

Showing 114 of 114 total issues

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

      const result = await (await db()).query(
        `
        INSERT INTO ${process.env.EDM_DB_SCHEMA}.events
         ("inventoryUuid", date, data)
        VALUES ($1, $2, $3)
Severity: Major
Found in backend/src/app/server-events.ts and 1 other location - About 1 hr to fix
backend/src/app/client-events.ts on lines 212..219

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

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

  private async fetchSingleInventoryEvents(
    inventoryUuid: string
  ): Promise<void> {
    let res: Event[] = await this.api
      .get<Event[]>(this.baseUrl + "/events/" + inventoryUuid)
Severity: Minor
Found in frontend/src/app/services/EventSourcing/event-sourcing.service.ts - 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 deleteInventory has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  async deleteInventory(): Promise<void> {
    const dialogRef: MatDialogRef<any> = this.dialog.open(
      DeleteConfirmationDialogComponent,
      {
        data: { inventory: this.inventory }

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

    const result = await (await db()).query(
      `
      INSERT INTO ${process.env.EDM_DB_SCHEMA}.events
       ("inventoryUuid", date, data)
      VALUES ($1, $2, $3)
Severity: Major
Found in backend/src/app/client-events.ts and 1 other location - About 1 hr to fix
backend/src/app/server-events.ts on lines 70..77

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

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

  private async handleLogin(req: Request, res: Response) {
    try {
      /**
       * The saltedPwdHash from the users projection
       */
Severity: Minor
Found in backend/src/app/authentication.ts - About 1 hr to fix

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

          data: {
            itemType: itemType.THING,
            crudType: crudType.DELETE,
            userUuid: (await this.as.getCurrentUser()).user.uuid,
            uuid: thing.uuid
    Severity: Major
    Found in frontend/src/app/services/thing/thing.service.ts and 1 other location - About 1 hr to fix
    frontend/src/app/services/category/category.service.ts on lines 350..355

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

    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

          data: {
            crudType: crudType.DELETE,
            itemType: itemType.CATEGORY,
            userUuid: (await this.as.getCurrentUser()).user.uuid,
            uuid: category.uuid
    Severity: Major
    Found in frontend/src/app/services/category/category.service.ts and 1 other location - About 1 hr to fix
    frontend/src/app/services/thing/thing.service.ts on lines 232..237

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

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

      private updateInventoriesProjection(event: Event): Inventory {
        /**
         * The inventory to be created or updated (ignored for delete events)
         */
        const newInventory = {
    Severity: Minor
    Found in frontend/src/app/services/inventory/inventory.service.ts - About 1 hr to fix

      Function handleRegister has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private async handleRegister(req: Request, res: Response) {
          // Check for duplicate email
          if (
            Authentication.usersProjection.find((user: User) => {
              return user.email === req.body.email;
      Severity: Minor
      Found in backend/src/app/authentication.ts - About 1 hr to fix

        Function updateStock has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async updateStock(
            stock: Stock,
            inventoryUuid: string,
            thingUuid: string
          ): Promise<void> {
        Severity: Minor
        Found in frontend/src/app/services/stock/stock.service.ts - About 1 hr to fix

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

            canActivateChild(
              next: ActivatedRouteSnapshot,
              state: RouterStateSnapshot
            ):
              | Observable<boolean | UrlTree>
          Severity: Major
          Found in frontend/src/app/guards/no-offline.guard.ts and 1 other location - About 1 hr to fix
          frontend/src/app/guards/no-offline.guard.ts on lines 15..24

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

          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

            canActivate(
              next: ActivatedRouteSnapshot,
              state: RouterStateSnapshot
            ):
              | Observable<boolean | UrlTree>
          Severity: Major
          Found in frontend/src/app/guards/no-offline.guard.ts and 1 other location - About 1 hr to fix
          frontend/src/app/guards/no-offline.guard.ts on lines 25..34

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

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

          module.exports = function (config) {
            config.set({
              basePath: '',
              frameworks: ['jasmine', '@angular-devkit/build-angular'],
              plugins: [
          Severity: Minor
          Found in frontend/karma.conf.js - About 1 hr to fix

            Function applyThingEvent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private applyThingEvent(event: Event, inventoryUuid: string) {
                /**
                 * The index of the event in the projection, if any
                 */
                const index = ThingService.inventoryTingsProjection[
            Severity: Minor
            Found in frontend/src/app/services/thing/thing.service.ts - About 1 hr to fix

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

                public static updateUsersProjection(event: UserEvent) {
                  const index = Authentication.usersProjection.findIndex(
                    (user: User) => user.uuid === event.data.userUuid,
                  );
              
              
              Severity: Minor
              Found in backend/src/app/authentication.ts - About 1 hr to fix

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

                  async ngOnInit() {
                    this.inventoryUuid = this.route.snapshot.params.inventoryUuid;
                    this.thingUuid = this.route.snapshot.params.thingUuid;
                
                    await this.is.ready;
                Severity: Minor
                Found in frontend/src/app/components/add-stock/add-stock.component.ts - About 1 hr to fix

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

                    async getCurrentUser(): Promise<GetStatusResponse> {
                      let response: GetStatusResponse;
                  
                      try {
                        // Try to get the data from the API
                  Severity: Minor
                  Found in frontend/src/app/services/auth/auth.service.ts - About 1 hr to fix

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

                      async ngOnInit(): Promise<void> {
                        this.inventoryUuid = this.route.snapshot.params.inventoryUuid;
                        this.thingUuid = this.route.snapshot.params.thingUuid;
                    
                        await this.is.ready;
                    Severity: Minor
                    Found in frontend/src/app/components/edit-thing/edit-thing.component.ts - About 1 hr to fix

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

                        constructor(
                          private is: InventoryService,
                          private ts: ThingService,
                      
                          private route: ActivatedRoute,
                      frontend/src/app/components/edit-inventory/edit-inventory.component.ts on lines 26..36
                      frontend/src/app/components/register/register.component.ts on lines 20..30

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

                      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

                      export class CategoryCardComponent implements OnInit {
                      
                        constructor() { }
                      
                        ngOnInit() {
                      frontend/src/app/components/add-category/add-category.component.ts on lines 8..15
                      frontend/src/app/components/page-not-found/page-not-found.component.ts on lines 8..15

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

                      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