markusbohl/fluent-ts-validator

View on GitHub

Showing 9 of 319 total issues

File AbstractValidator.spec.ts has 364 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {AbstractValidator, ValidationResult} from "./";
import {Severity, ValidationFailure} from "./shared";

class TestPerson {
    name?: string;
Severity: Minor
Found in src/AbstractValidator.spec.ts - About 4 hrs to fix

    File CommonValidatorBuilderImpl.spec.ts has 344 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {AbstractValidator} from "../";
    import {CommonValidatorBuilder, CommonValidatorBuilderImpl, ValidationOptionsBuilder} from "./";
    import {Severity, ValidationFailure} from "../shared";
    import {
        UnlessCondition,
    Severity: Minor
    Found in src/builder/CommonValidatorBuilderImpl.spec.ts - About 4 hrs to fix

      File StringValidatorBuilderImpl.spec.ts has 315 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import {ValidationRule, WhenNotEmptyCondition} from "../validation";
      import {
          ContainsValidator,
          HasLengthValidator,
          IsAlphanumericValidator,
      Severity: Minor
      Found in src/builder/StringValidatorBuilderImpl.spec.ts - About 3 hrs to fix

        StringValidatorBuilderImpl has 29 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class StringValidatorBuilderImpl<T> extends CommonValidatorBuilderImpl<T, string> implements StringValidatorBuilder<T>, StringValidationOptionsBuilder<T> {
        
            constructor(validationRule: ValidationRule<T, string | Iterable<string>>) {
                super(validationRule);
            }
        Severity: Minor
        Found in src/builder/StringValidatorBuilderImpl.ts - About 3 hrs to fix

          CommonValidatorBuilderImpl has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class CommonValidatorBuilderImpl<T, TProperty> implements ValidationOptionsBuilder<T>,
              CommonValidatorBuilder<T, TProperty> {
          
              constructor(protected validationRule: ValidationRule<T, TProperty | Iterable<TProperty>>) {
              }
          Severity: Minor
          Found in src/builder/CommonValidatorBuilderImpl.ts - About 2 hrs to fix

            Function isValid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                isValid(input: Date | undefined): boolean {
                    if (typeof input === "undefined" || input === null) {
                        return false;
                    } else if (this.lowerBoundary === "[" && this.upperBoundary === "]") {
                        return this.lowerDate.getTime() <= input.getTime() && input.getTime() <= this.upperDate.getTime();
            Severity: Minor
            Found in src/validators/date-based/IsBetweenValidator.ts - About 45 mins 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

            Avoid too many return statements within this function.
            Open

                        return this.lowerDate.getTime() < input.getTime() && input.getTime() < this.upperDate.getTime();
            Severity: Major
            Found in src/validators/date-based/IsBetweenValidator.ts - About 30 mins to fix

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

                  isValid(input: Iterable<TProperty> | undefined): boolean {
                      if (input) {
                          for (let element of input) {
                              if (element === this.seed) {
                                  return true;
              Severity: Minor
              Found in src/validators/collection-based/ContainsElementValidator.ts - About 25 mins 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 isValid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  isValid(input: Iterable<TProperty> | undefined): boolean {
                      if (input) {
                          for (let element of input) {
                              if (element === this.nonSeed) {
                                  return false;
              Severity: Minor
              Found in src/validators/collection-based/DoesNotContainElementValidator.ts - About 25 mins 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

              Severity
              Category
              Status
              Source
              Language