kalidea/kaligraphi

View on GitHub
projects/kalidea/kaligraphi/src/lib/02-form/kal-select/kal-select.component.ts

Summary

Maintainability
C
1 day
Test Coverage

File kal-select.component.ts has 360 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  AfterContentInit,
  ChangeDetectionStrategy,
  ChangeDetectorRef,
  Component,

    KalSelectComponent has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
      selector: 'kal-select',
      exportAs: 'kalSelect',
      templateUrl: './kal-select.component.html',
      styleUrls: ['./kal-select.sass'],

      Function triggerValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        get triggerValue(): string {
          if (!this.selection || this.selection.length === 0) {
            return null;
          }
      
      

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

        select(value: any, withNotify = false): void {
          if (this.isMultiple && value instanceof Array) {
            const multipleOptions = this.options.filter((item) => value.indexOf(item.value) >= 0);
            this.multipleOptionSelected(multipleOptions, withNotify);
          } else {

      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 5 locations. Consider refactoring.
      Open

      @Component({
        selector: 'kal-select',
        exportAs: 'kalSelect',
        templateUrl: './kal-select.component.html',
        styleUrls: ['./kal-select.sass'],
      projects/kalidea/kaligraphi/src/lib/02-form/kal-checkbox/kal-checkbox.component.ts on lines 22..136
      projects/kalidea/kaligraphi/src/lib/02-form/kal-datepicker/kal-datepicker.component.ts on lines 46..421
      projects/kalidea/kaligraphi/src/lib/02-form/kal-input/kal-input.component.ts on lines 42..241
      projects/kalidea/kaligraphi/src/lib/02-form/kal-textarea/kal-textarea.component.ts on lines 19..85

      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

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

          this.overlayRef.keydownEvents()
            .pipe(filter(event => event.keyCode === ESCAPE))
            .subscribe(() => this.close());
      projects/kalidea/kaligraphi/src/lib/02-form/kal-datepicker/kal-datepicker.component.ts on lines 374..378

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

      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

      Missing semicolon
      Open

          })

      Rule: semicolon

      Enforces consistent semicolon usage at the end of every statement.

      Notes
      • Has Fix

      Config

      One of the following arguments must be provided:

      • "always" enforces semicolons at the end of every statement.
      • "never" disallows semicolons at the end of every statement except for when they are necessary.

      The following arguments may be optionally provided:

      • "ignore-interfaces" skips checking semicolons at the end of interface members.
      • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
      • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
      Examples
      "semicolon": true,always
      "semicolon": true,never
      "semicolon": true,always,ignore-interfaces
      "semicolon": true,always,ignore-bound-class-methods
      Schema
      {
        "type": "array",
        "items": [
          {
            "type": "string",
            "enum": [
              "always",
              "never"
            ]
          },
          {
            "type": "string",
            "enum": [
              "ignore-interfaces"
            ]
          }
        ],
        "additionalItems": false
      }

      For more information see this page.

      Missing semicolon
      Open

              this.selection.splice(this.selection.indexOf(option), 1)

      Rule: semicolon

      Enforces consistent semicolon usage at the end of every statement.

      Notes
      • Has Fix

      Config

      One of the following arguments must be provided:

      • "always" enforces semicolons at the end of every statement.
      • "never" disallows semicolons at the end of every statement except for when they are necessary.

      The following arguments may be optionally provided:

      • "ignore-interfaces" skips checking semicolons at the end of interface members.
      • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
      • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
      Examples
      "semicolon": true,always
      "semicolon": true,never
      "semicolon": true,always,ignore-interfaces
      "semicolon": true,always,ignore-bound-class-methods
      Schema
      {
        "type": "array",
        "items": [
          {
            "type": "string",
            "enum": [
              "always",
              "never"
            ]
          },
          {
            "type": "string",
            "enum": [
              "ignore-interfaces"
            ]
          }
        ],
        "additionalItems": false
      }

      For more information see this page.

      jsdoc is not formatted correctly on this line
      Open

         Sets up a key manager to listen to keyboard events on the overlay panel.

      Rule: jsdoc-format

      Enforces basic format rules for JSDoc comments.

      The following rules are enforced for JSDoc comments (comments starting with /**):

      • each line contains an asterisk and asterisks must be aligned
      • each asterisk must be followed by either a space or a newline (except for the first and the last)
      • the only characters before the asterisk on each line must be whitespace characters
      • one line comments must start with /** and end with */
      • multiline comments don't allow text after /** in the first line (with option "check-multiline-start")
      Rationale

      Helps maintain a consistent, readable style for JSDoc comments.

      Config

      You can optionally specify the option "check-multiline-start" to enforce the first line of a multiline JSDoc comment to be empty.

      Examples
      "jsdoc-format": true
      "jsdoc-format": true,check-multiline-start
      Schema
      {
        "type": "array",
        "minItems": 0,
        "maxItems": 1,
        "items": {
          "type": "string",
          "enum": [
            "check-multiline-start"
          ]
        }
      }

      For more information see this page.

      asterisks in jsdoc must be aligned
      Open

         Sets up a key manager to listen to keyboard events on the overlay panel.

      Rule: jsdoc-format

      Enforces basic format rules for JSDoc comments.

      The following rules are enforced for JSDoc comments (comments starting with /**):

      • each line contains an asterisk and asterisks must be aligned
      • each asterisk must be followed by either a space or a newline (except for the first and the last)
      • the only characters before the asterisk on each line must be whitespace characters
      • one line comments must start with /** and end with */
      • multiline comments don't allow text after /** in the first line (with option "check-multiline-start")
      Rationale

      Helps maintain a consistent, readable style for JSDoc comments.

      Config

      You can optionally specify the option "check-multiline-start" to enforce the first line of a multiline JSDoc comment to be empty.

      Examples
      "jsdoc-format": true
      "jsdoc-format": true,check-multiline-start
      Schema
      {
        "type": "array",
        "minItems": 0,
        "maxItems": 1,
        "items": {
          "type": "string",
          "enum": [
            "check-multiline-start"
          ]
        }
      }

      For more information see this page.

      comment must start with a space
      Open

          //select options that were not already selected

      Rule: comment-format

      Enforces formatting rules for single-line comments.

      Rationale

      Helps maintain a consistent, readable style in your codebase.

      Notes
      • Has Fix

      Config

      Four arguments may be optionally provided:

      • "check-space" requires that all single-line comments must begin with a space, as in // comment
        • note that for comments starting with multiple slashes, e.g. ///, leading slashes are ignored
        • TypeScript reference comments are ignored completely
      • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
      • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
      • "allow-trailing-lowercase" allows that only the first comment of a series of comments needs to be uppercase.
        • requires "check-uppercase"
        • comments must start at the same position

      Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.

      One of two options can be provided in this object:

      • "ignore-words" - array of strings - words that will be ignored at the beginning of the comment.
      • "ignore-pattern" - string - RegExp pattern that will be ignored at the beginning of the comment.
      Examples
      "comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
      "comment-format": true,check-lowercase,[object Object]
      "comment-format": true,check-lowercase,[object Object]
      Schema
      {
        "type": "array",
        "items": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "check-space",
                "check-lowercase",
                "check-uppercase",
                "allow-trailing-lowercase"
              ]
            },
            {
              "type": "object",
              "properties": {
                "ignore-words": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "ignore-pattern": {
                  "type": "string"
                }
              },
              "minProperties": 1,
              "maxProperties": 1
            }
          ]
        },
        "minLength": 1,
        "maxLength": 5
      }

      For more information see this page.

      There are no issues that match your filters.

      Category
      Status