hisptz/ngx-dhis2-http-client

View on GitHub

Showing 19 of 19 total issues

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

    put(url: string, data: any, httpConfig?: HttpConfig) {
        const newHttpConfig = this._getHttpConfig(httpConfig);

        const httpOptions = this._getHttpOptions(newHttpConfig.httpHeaders);
        return this._getRootUrl(newHttpConfig).pipe(
projects/ngx-dhis2-http-client/src/lib/services/ngx-dhis2-http-client.service.ts on lines 123..137

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

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

    post(url: string, data: any, httpConfig?: HttpConfig) {
        const newHttpConfig = this._getHttpConfig(httpConfig);

        const httpOptions = this._getHttpOptions(newHttpConfig.httpHeaders);

projects/ngx-dhis2-http-client/src/lib/services/ngx-dhis2-http-client.service.ts on lines 139..152

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File ngx-dhis2-http-client.service.ts has 327 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
    HttpClient,
    HttpErrorResponse,
    HttpHeaders,
} from '@angular/common/http';

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

            return this._getRootUrl(newHttpConfig).pipe(
                mergeMap(rootUrl =>
                    (httpOptions
                        ? this.httpClient.delete(rootUrl + url, httpOptions)
                        : this.httpClient.delete(rootUrl + url)
    projects/ngx-dhis2-http-client/src/lib/services/ngx-dhis2-http-client.service.ts on lines 276..284

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

    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 this._getRootUrl(httpConfig).pipe(
                mergeMap(rootUrl =>
                    (httpOptions
                        ? this.httpClient.get(rootUrl + url, httpOptions)
                        : this.httpClient.get(rootUrl + url)
    projects/ngx-dhis2-http-client/src/lib/services/ngx-dhis2-http-client.service.ts on lines 158..166

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

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

        private _getFromIndexDb(url, httpConfig: HttpConfig, httpOptions: any) {
            const urlContent = deduceUrlContent(url);
            const schemaName =
                urlContent && urlContent.schema
                    ? urlContent.schema.name

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

          private _getTableSchema(schemaName: string, params: IndexDBParams) {
              const tableSchema = this.table(schemaName);
              if (!params) {
                  return tableSchema;
              }
      Severity: Minor
      Found in projects/ngx-dhis2-http-client/src/lib/services/index-db.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 filterDataItem has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function filterDataItem(dataItem: any, filterList: any[]) {
          return (filterList || []).some((filterItem: any) => {
              const { attribute, condition, filterValue } = filterItem;
              switch (condition) {
                  case 'ilike': {

        Function init has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            init() {
                this.manifestService
                    .getManifest(this.httpClient)
                    .pipe(
                        switchMap((manifest: Manifest) => {

          Function _getTableSchema has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private _getTableSchema(schemaName: string, params: IndexDBParams) {
                  const tableSchema = this.table(schemaName);
                  if (!params) {
                      return tableSchema;
                  }
          Severity: Minor
          Found in projects/ngx-dhis2-http-client/src/lib/services/index-db.service.ts - About 1 hr to fix

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

                systemInfo(): Observable<SystemInfo> {
                    return this._getInstance().pipe(
                        map((instance: Instance) => instance.systemInfo)
                    );
                }
            projects/ngx-dhis2-http-client/src/lib/services/ngx-dhis2-http-client.service.ts on lines 169..173

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

            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

                me(): Observable<User> {
                    return this._getInstance().pipe(
                        map((instance: Instance) => instance.currentUser)
                    );
                }
            projects/ngx-dhis2-http-client/src/lib/services/ngx-dhis2-http-client.service.ts on lines 175..179

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

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

                private _getFromIndexDb(url, httpConfig: HttpConfig, httpOptions: any) {
                    const urlContent = deduceUrlContent(url);
                    const schemaName =
                        urlContent && urlContent.schema
                            ? urlContent.schema.name

            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

            Avoid too many return statements within this function.
            Open

                            return (
                                parseInt(dataItem[attribute], 10) >=
                                parseInt(filterValue, 10)
                            );

              Avoid too many return statements within this function.
              Open

                              return (
                                  parseInt(dataItem[attribute], 10) >
                                  parseInt(filterValue, 10)
                              );

                Avoid too many return statements within this function.
                Open

                                return tableSchema;
                Severity: Major
                Found in projects/ngx-dhis2-http-client/src/lib/services/index-db.service.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return tableSchema.orderBy(orderByColumns[0]);
                  Severity: Major
                  Found in projects/ngx-dhis2-http-client/src/lib/services/index-db.service.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return (filterValue || '').indexOf(dataItem[attribute]) !== -1;

                      Avoid too many return statements within this function.
                      Open

                              return tableSchema;
                      Severity: Major
                      Found in projects/ngx-dhis2-http-client/src/lib/services/index-db.service.ts - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language