flut1/knockout-validator

View on GitHub

Showing 19 of 31 total issues

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

    private _applyValidationClasses():void
    {
        if(this._validator && this._element)
        {
            const isValid = this.isValid();
Severity: Minor
Found in src/lib/fields/Field.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 parseBindingRule has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const parseBindingRule = (rule:RuleBindingValue, name:string = null):RuleState =>
{
    switch(typeof rule)
    {
        case 'object':
Severity: Major
Found in src/lib/rules/parseBindingRule.ts - About 2 hrs to fix

    Function parseBindingRule has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    const parseBindingRule = (rule:RuleBindingValue, name:string = null):RuleState =>
    {
        switch(typeof rule)
        {
            case 'object':
    Severity: Minor
    Found in src/lib/rules/parseBindingRule.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 exports has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function (config)
    {
        config.set({
            frameworks: ['mocha', 'chai'],
            files: [
    Severity: Minor
    Found in karma.conf.js - About 1 hr to fix

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

      const getAllBindingValues = (element:HTMLElement, allBindingsAccessor:ko.AllBindingsAccessor, bindingContext:ko.BindingContext<any>):{[name:string]:BindingDescriptor} =>
      {
          const shorthandValues = allBindingsAccessor.get(SHORTHAND_BINDING_NAME) || {};
          const allBindings:{[name:string]:BindingDescriptor} = {};
      
      
      Severity: Minor
      Found in src/lib/bindings/genericBindingHandler.ts - About 1 hr to fix

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

        module.exports = function()
        {
            return {
                resolve: {
                    extensions: ['', '.ts', '.js']
        Severity: Minor
        Found in config/webpack.config.test.js - About 1 hr to fix

          Function createValueBinding has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const createValueBinding = (element:HTMLElement, allBindingsAccessor:ko.AllBindingsAccessor, viewModel:any, bindingContext:ko.BindingContext<any>):ko.Observable<any> =>
          {
              const hasValueBinding = allBindingsAccessor.has('value');
              const valueBindingKey = getValueBindingKey(element);
              if(valueBindingKey == 'selectedOptions' && hasValueBinding)
          Severity: Minor
          Found in src/lib/bindings/genericBindingHandler.ts - About 1 hr to fix

            Function validate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public validate(value:any):Promise<boolean>
                {
                    let validation:Promise<boolean>;
                    switch(this.ruleType)
                    {
            Severity: Minor
            Found in src/lib/rules/RuleState.ts - About 1 hr to fix

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

                  constructor(
                      name:string,
                      ruleType:RuleType,
                      test:any
                  )
              Severity: Minor
              Found in src/lib/rules/RuleState.ts - About 1 hr to fix

                Function getValueBindingKey has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const getValueBindingKey = (element:HTMLElement):string =>
                {
                    const tagName = element.tagName.toLowerCase();
                    const typeAttr = element.getAttribute('type');
                    let valueBindingKey = 'value';
                Severity: Minor
                Found in src/lib/bindings/genericBindingHandler.ts - About 1 hr to fix

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

                  module.exports = function()
                  {
                      return {
                          resolve: {
                              extensions: ['', '.ts', '.js']
                  Severity: Minor
                  Found in config/webpack.config.dist.js - About 1 hr to fix

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

                        constructor()
                        {
                            super();
                    
                            this.isValidated = ko.pureComputed(() =>
                    Severity: Minor
                    Found in src/lib/fields/FieldCollection.ts - About 1 hr to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if(typeof shorthandValues[binding.bindingShorthand] !== 'undefined')
                                          {
                                              field[binding.validatorFieldProp] = shorthandValues[binding.bindingShorthand];
                                          }
                      Severity: Major
                      Found in src/lib/bindings/genericBindingHandler.ts - About 45 mins to fix

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

                        export const getValueBindingKey = (element:HTMLElement):string =>
                        {
                            const tagName = element.tagName.toLowerCase();
                            const typeAttr = element.getAttribute('type');
                            let valueBindingKey = 'value';
                        Severity: Minor
                        Found in src/lib/bindings/genericBindingHandler.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

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

                            constructor()
                            {
                                super();
                        
                                this.isValidated = ko.pureComputed(() =>
                        Severity: Minor
                        Found in src/lib/fields/FieldCollection.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 deeply nested control flow statements.
                        Open

                                        if(binding)
                                        {
                                            field[binding.validatorFieldProp] = value;
                                        }
                        Severity: Major
                        Found in src/lib/bindings/genericBindingHandler.ts - About 45 mins to fix

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

                          export const createValueBinding = (element:HTMLElement, allBindingsAccessor:ko.AllBindingsAccessor, viewModel:any, bindingContext:ko.BindingContext<any>):ko.Observable<any> =>
                          {
                              const hasValueBinding = allBindingsAccessor.has('value');
                              const valueBindingKey = getValueBindingKey(element);
                              if(valueBindingKey == 'selectedOptions' && hasValueBinding)
                          Severity: Minor
                          Found in src/lib/bindings/genericBindingHandler.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

                          Function validateOn has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public set validateOn(validateOn:string)
                              {
                                  if(this._validateOn !== validateOn)
                                  {
                                      this._autoValidate = false;
                          Severity: Minor
                          Found in src/lib/fields/FieldCollection.ts - About 35 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 _initComputed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private _initComputed():void
                              {
                                  this.isValid = ko.pureComputed(() =>
                                  {
                                      const fields = this._fields();
                          Severity: Minor
                          Found in src/lib/KnockoutValidator.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