uchaindb/UClient

View on GitHub

Showing 2,037 of 2,037 total issues

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

        let mapColumnData = (obj): Array<ColumnData> => {
            if (!obj) return null;
            let ret = Object.keys(obj).map(_ => (<ColumnData>{ Name: _, Data: obj[_] }));
            if (ret.length == 0) return null;
            return ret;
src/ClientApp/app/components/database/create.page.function.ts on lines 78..83
src/ClientApp/app/components/database/create.page.function.ts on lines 129..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 100.

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

        let mapColumnData = (obj): Array<ColumnData> => {
            if (!obj) return null;
            let ret = Object.keys(obj).map(_ => (<ColumnData>{ Name: _, Data: obj[_] }));
            if (ret.length == 0) return null;
            return ret;
src/ClientApp/app/components/database/create.page.function.ts on lines 78..83
src/ClientApp/app/components/database/create.page.function.ts on lines 157..162

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

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

        let mapColumnData = (obj): Array<ColumnData> => {
            if (!obj) return null;
            let ret = Object.keys(obj).map(_ => (<ColumnData>{ Name: _, Data: obj[_] }));
            if (ret.length == 0) return null;
            return ret;
src/ClientApp/app/components/database/create.page.function.ts on lines 129..134
src/ClientApp/app/components/database/create.page.function.ts on lines 157..162

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

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

    generateActions(txs: Array<Tx>) {
        if (!txs) {
            this.dataActions = [];
            this.schemaActions = [];
            this.lockTxs = [];
Severity: Minor
Found in src/ClientApp/app/components/database/action.component.ts - About 3 hrs 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

Utilities has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

@Injectable()
export class Utilities {

    public static readonly captionAndMessageSeparator = ":";
    public static readonly noNetworkMessageCaption = "无网络";
Severity: Minor
Found in src/ClientApp/app/services/utilities.ts - About 3 hrs to fix

    Function generateNotification has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        private generateNotification(alarms: Array<AlarmConfiguration>): Observable<Array<AlarmConfiguration>> {
            var dbArray = alarms
                .map(_ => _.dbid)
                .filter((v, i, a) => a.indexOf(v) === i);
            for (var i = 0; i < dbArray.length; i++) {
    Severity: Minor
    Found in src/ClientApp/app/services/alarm.service.ts - About 3 hrs 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

    ChainDbService has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Injectable()
    export class ChainDbService extends EndpointFactory {
        private readonly _baseUrl: string = "";
        get baseUrl() { return this.configurations.baseUrl + this._baseUrl; }
    
    
    Severity: Minor
    Found in src/ClientApp/app/services/chain-db.service.ts - About 3 hrs to fix

      File login.page.ts has 290 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { Component, OnInit, OnDestroy, Input, Inject, isDevMode } from "@angular/core";
      import { DOCUMENT } from '@angular/platform-browser';
      
      import { AlertService, MessageSeverity, DialogType } from '../../services/alert.service';
      import { AuthService } from "../../services/auth.service";
      Severity: Minor
      Found in src/ClientApp/app/components/user/login.page.ts - About 2 hrs to fix

        Function exports has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = (env) => {
            // Configuration in common to both client-side and server-side bundles
            const isDevBuild = !(env && env.prod);
            const extractCSS = new ExtractTextPlugin('vendor.css');
            const sharedConfig = {
        Severity: Major
        Found in src/webpack.config.js - About 2 hrs to fix

          Function constructor has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              constructor(
                  private alertService: AlertService,
                  private authService: AuthService,
                  private configurations: ConfigurationService,
                  private translationService: AppTranslationService,
          Severity: Major
          Found in src/ClientApp/app/components/user/login.page.ts - About 2 hrs to fix

            Function getHttpResponseMessage has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                public static getHttpResponseMessage(data: Response | any): string[] {
            
                    let responses: string[] = [];
            
                    if (data instanceof Response) {
            Severity: Minor
            Found in src/ClientApp/app/services/utilities.ts - About 2 hrs 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

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

                constructor(
                    private notifyService: NotificationService,
                    private alertService: AlertService,
                    private route: ActivatedRoute,
                    private router: Router,
            Severity: Major
            Found in src/ClientApp/app/components/alarm/detail.page.ts and 1 other location - About 2 hrs to fix
            src/ClientApp/app/components/database/list.page.ts on lines 21..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 88.

            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

                constructor(
                    private dataService: ChainDbService,
                    private alertService: AlertService,
                    private translationService: AppTranslationService,
                ) {
            Severity: Major
            Found in src/ClientApp/app/components/database/list.page.ts and 1 other location - About 2 hrs to fix
            src/ClientApp/app/components/alarm/detail.page.ts on lines 23..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 88.

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

                constructor(private location: Location,
                    titleService: Title,
                    private router: Router,
                    private authService: AuthService,
                    private alertService: AlertService,
            Severity: Major
            Found in src/ClientApp/app/components/app/app.component.ts - About 2 hrs to fix

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

                              this.dataService.getDbList()
                                  .subscribe(_ => {
                                      this.alarmConfigs.forEach(a => (<any>a).dbname = _.find(d => d.id == a.dbid).name);
                                  });
              Severity: Major
              Found in src/ClientApp/app/components/database/detail.page.ts and 2 other locations - About 2 hrs to fix
              src/ClientApp/app/components/database/table.component.ts on lines 97..100
              src/ClientApp/app/components/database/table.page.ts on lines 93..96

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

              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

                              this.dataService.getDbList()
                                  .subscribe(_ => {
                                      this.alarmConfigs.forEach(a => (<any>a).dbname = _.find(d => d.id == a.dbid).name);
                                  });
              Severity: Major
              Found in src/ClientApp/app/components/database/table.page.ts and 2 other locations - About 2 hrs to fix
              src/ClientApp/app/components/database/detail.page.ts on lines 121..124
              src/ClientApp/app/components/database/table.component.ts on lines 97..100

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

              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

                              this.dataService.getDbList()
                                  .subscribe(_ => {
                                      this.alarmConfigs.forEach(a => (<any>a).dbname = _.find(d => d.id == a.dbid).name);
                                  });
              Severity: Major
              Found in src/ClientApp/app/components/database/table.component.ts and 2 other locations - About 2 hrs to fix
              src/ClientApp/app/components/database/detail.page.ts on lines 121..124
              src/ClientApp/app/components/database/table.page.ts on lines 93..96

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

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

                  public static findHttpResponseMessage(messageToFind: string, data: Response | any, seachInCaptionOnly = true, includeCaptionInResult = false): string {
              
                      let searchString = messageToFind.toLowerCase();
                      let httpMessages = this.getHttpResponseMessage(data);
              
              
              Severity: Minor
              Found in src/ClientApp/app/services/utilities.ts - About 2 hrs 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 getActionDefinitions has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  static getActionDefinitions(translationService: AppTranslationService) {
                      let gT = (key: string) => translationService.getTranslation(key);
                      let baseActionDef = {
                          filter: { inputClass: "hidden" },
                          attr: { class: "table table-bordered table-reset" },
              Severity: Major
              Found in src/ClientApp/app/components/database/create.page.translation.ts - About 2 hrs to fix

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

                            this.cacheUrlContent[key] = this.http.get(endpointUrl)//, this.getAuthHeader())
                                .map((response: Response) => response)
                                .publishReplay(1)
                                .refCount()
                                .catch(error => this.handleError(error, () => this.getUrlContentEndpoint(url, forceUpdate)));
                Severity: Major
                Found in src/ClientApp/app/services/uitext.service.ts and 1 other location - About 2 hrs to fix
                src/ClientApp/app/services/uitext.service.ts on lines 51..55

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

                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