src/lib/bindings/genericBindingHandler.ts
Function getAllBindingValues
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
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} = {};
Function createValueBinding
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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)
Function getValueBindingKey
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const getValueBindingKey = (element:HTMLElement):string =>
{
const tagName = element.tagName.toLowerCase();
const typeAttr = element.getAttribute('type');
let valueBindingKey = 'value';
Function getValueBindingKey
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
export const getValueBindingKey = (element:HTMLElement):string =>
{
const tagName = element.tagName.toLowerCase();
const typeAttr = element.getAttribute('type');
let valueBindingKey = 'value';
- Read upRead up
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
Open
if(typeof shorthandValues[binding.bindingShorthand] !== 'undefined')
{
field[binding.validatorFieldProp] = shorthandValues[binding.bindingShorthand];
}
Function createValueBinding
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
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)
- Read upRead up
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
Open
if(binding)
{
field[binding.validatorFieldProp] = value;
}