uchaindb/UClient

View on GitHub

Showing 2,037 of 2,037 total issues

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

            this.cacheArticleList = this.http.get(endpointUrl)//, this.getAuthHeader())
                .map((response: Response) => response)
                .publishReplay(1)
                .refCount()
                .catch(error => this.handleError(error, () => this.getArticleListEndpoint(pager, 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 29..33

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

Function onKeyDown has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    @HostListener('keydown', ['$event']) onKeyDown(event) {
        let e = <KeyboardEvent>event;
        if (this.OnlyNumber) {
            if ([46, 8, 9, 27, 13, 110, 190].indexOf(e.keyCode) !== -1 ||
                // Allow: Ctrl+A
Severity: Minor
Found in src/ClientApp/app/directives/only-number.directive.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 getSchemaActions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    static getSchemaActions(arr: Array<SchemaActionCreationType>): Array<SchemaAction> {
        let getSchemaType = (type: SchemaActionCreationTypeEnum): SchemaActionEnum =>
            type == "create" ? "CreateSchemaAction"
                : type == "modify" ? "ModifySchemaAction"
                    : "DropSchemaAction";
Severity: Minor
Found in src/ClientApp/app/components/database/create.page.function.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

    private generateUnlockScriptsForDataTx(privateKey: PrivateKey, initiator: Address, witness: string, actions: Array<DataAction>): string {
        if (!privateKey) return null;
        let hashContent = this.getDataTxHashContent(initiator, witness, actions);
        return this.generateUnlockScriptsForTx(privateKey, hashContent);
    }
Severity: Major
Found in src/ClientApp/app/services/chain-db.service.ts and 1 other location - About 2 hrs to fix
src/ClientApp/app/services/chain-db.service.ts on lines 271..275

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

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

    private generateUnlockScriptsForSchemaTx(privateKey: PrivateKey, initiator: Address, witness: string, actions: Array<SchemaAction>): string {
        if (!privateKey) return null;
        let hashContent = this.getSchemaTxHashContent(initiator, witness, actions);
        return this.generateUnlockScriptsForTx(privateKey, hashContent);
    }
Severity: Major
Found in src/ClientApp/app/services/chain-db.service.ts and 1 other location - About 2 hrs to fix
src/ClientApp/app/services/chain-db.service.ts on lines 265..269

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

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 chain-db.model.ts has 256 lines of code (exceeds 250 allowed). Consider refactoring.
Open

export class ChainDb {
    constructor(obj: ChainDb = {} as ChainDb) {
        let {
            id = null,
            name = null,
Severity: Minor
Found in src/ClientApp/app/models/chain-db.model.ts - About 2 hrs to fix

    Function generateActions has 50 lines of code (exceeds 25 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 2 hrs to fix

      Function getSchemaActionCreationTypes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          static getSchemaActionCreationTypes(actions: Array<SchemaAction>): Array<SchemaActionCreationType> {
              let getSchemaType = (type: SchemaActionEnum): SchemaActionCreationTypeEnum =>
                  type == "CreateSchemaAction" ? "create"
                      : type == "ModifySchemaAction" ? "modify"
                          : "drop";
      Severity: Minor
      Found in src/ClientApp/app/components/database/create.page.function.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 fromB58 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          static fromB58(string: string): Uint8Array{
              this.initb58();
              var bytes, c, carry, j, i;
              if (string.length === 0) {
                  return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(0);
      Severity: Minor
      Found in src/ClientApp/app/services/b58.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

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

              let getDataType = (type: LockTargetCreationTypeEnum): LockTargetEnum =>
                  type == "database" ? "Database"
                      : type == "schema" ? "TableSchema"
                          : type == "row" ? "TableRowData"
                              : type == "column" ? "TableColumnData"
      src/ClientApp/app/components/database/create.page.function.ts on lines 149..155

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

      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

              let getDataType = (type: LockTargetEnum): LockTargetCreationTypeEnum =>
                  type == "Database" ? "database"
                      : type == "TableSchema" ? "schema"
                          : type == "TableRowData" ? "row"
                              : type == "TableColumnData" ? "column"
      src/ClientApp/app/components/database/create.page.function.ts on lines 121..127

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

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

          login() {
              this.isLoading = true;
              this.alertService.startLoadingMessage("", this.translations.loggingIn);
      
              var password = this.wxCode ? `${this.code}|${this.wxCode}` : this.code;
      Severity: Minor
      Found in src/ClientApp/app/components/user/login.page.ts - About 1 hr to fix

        Function unitTests has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            unitTests() {
                var privKey = this.generateRandomPrivateKey();
                var pubKey = this.getPublicKey(privKey);
                var sig = this.sign("中文", privKey);
                var ret = this.verify("中文", pubKey, sig);
        Severity: Minor
        Found in src/ClientApp/app/services/cryptography.service.ts - About 1 hr to fix

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

                  var lt = arr
                      .map<LockTarget>(_ => ({
                          TargetType: getDataType(_.type),
                          PublicPermission: _.permissions,
                          TableName: _.tableName,
          src/ClientApp/app/components/database/create.page.function.ts on lines 164..171

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

          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 targets
                      .map<LockTargetCreationType>(_ => ({
                          type: getDataType(_.TargetType),
                          permissions: _.PublicPermission,
                          tableName: _.TableName,
          src/ClientApp/app/components/database/create.page.function.ts on lines 136..143

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

          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 generateNotification has 41 lines of code (exceeds 25 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 1 hr to fix

            Function getChainDbTable has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                getChainDbTable(db: ChainDb, tableName: string, start: number = 0, size: number = 100): Observable<QueryTableResponse> {
                    return this.rpcCall(db.address, "QueryData", [tableName, start, size, "", ""]).
                        map((_: QueryDataRpcResponse) => {
                            let dataHist = _.DataHistories || [];
                            let pkname = _.PrimaryKeyName;
            Severity: Minor
            Found in src/ClientApp/app/services/chain-db.service.ts - About 1 hr to fix

              Function fromB58 has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  static fromB58(string: string): Uint8Array{
                      this.initb58();
                      var bytes, c, carry, j, i;
                      if (string.length === 0) {
                          return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(0);
              Severity: Minor
              Found in src/ClientApp/app/services/b58.ts - About 1 hr to fix

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

                        this.alertService.showDialog(this.translations.removeConfirmation, DialogType.confirm, () => {
                            this.dataService.removeChainDb(db);
                            this.alertService.showMessage(this.translations.databaseRemovedTitle, this.translations.databaseRemovedContent, MessageSeverity.success);
                            this.refresh();
                        });
                Severity: Major
                Found in src/ClientApp/app/components/database/list.page.ts and 1 other location - About 1 hr to fix
                src/ClientApp/app/components/database/detail.page.ts on lines 143..147

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

                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

                    remove(alarm: AlarmConfiguration) {
                        this.alarmService.removeConfig(alarm);
                        this.alertService.showMessage(this.translations.alarmListItemRemovedTitle, this.translations.alarmListItemRemovedContent, MessageSeverity.success);
                        this.refreshAlarms();
                    }
                Severity: Major
                Found in src/ClientApp/app/components/database/detail.page.ts and 1 other location - About 1 hr to fix
                src/ClientApp/app/components/database/list.page.ts on lines 44..48

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

                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