hisptz/ngx-dhis2-http-client

View on GitHub

Showing 13 of 19 total issues

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';

    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

            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