aurelia/aurelia

View on GitHub
packages/template-compiler/src/binding-command.ts

Summary

Maintainability
F
1 wk
Test Coverage

File binding-command.ts has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { IExpressionParser } from '@aurelia/expression-parser';
import { Protocol, camelCase, emptyArray, firstDefined, getResourceKeyFor, mergeArrays, resolve, resource, resourceBaseName } from '@aurelia/kernel';
import { defineMetadata, getMetadata } from './utilities-metadata';
import { IAttrMapper } from './attribute-mapper';
import {
Severity: Minor
Found in packages/template-compiler/src/binding-command.ts - About 5 hrs to fix

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

    export const BindingCommand = /*@__PURE__*/ (() => {
    
      const staticResourceDefinitionMetadataKey = '__au_static_resource__';
      const getDefinitionFromStaticAu = <Def extends ResourceDefinition, C extends Constructable = Constructable>(
        // eslint-disable-next-line @typescript-eslint/ban-types
    Severity: Minor
    Found in packages/template-compiler/src/binding-command.ts - About 1 hr to fix

      Function BindingCommand has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      export const BindingCommand = /*@__PURE__*/ (() => {
      
        const staticResourceDefinitionMetadataKey = '__au_static_resource__';
        const getDefinitionFromStaticAu = <Def extends ResourceDefinition, C extends Constructable = Constructable>(
          // eslint-disable-next-line @typescript-eslint/ban-types
      Severity: Minor
      Found in packages/template-compiler/src/binding-command.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 build has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        public build(info: ICommandBuildInfo, exprParser: IExpressionParser, attrMapper: IAttrMapper): PropertyBindingInstruction {
          const attr = info.attr;
          const bindable = info.bindable;
          let value = attr.rawValue;
          let target = attr.target;
      Severity: Minor
      Found in packages/template-compiler/src/binding-command.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 build has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public build(info: ICommandBuildInfo, exprParser: IExpressionParser, attrMapper: IAttrMapper): PropertyBindingInstruction {
          const attr = info.attr;
          const bindable = info.bindable;
          let value = attr.rawValue;
          let target = attr.target;
      Severity: Minor
      Found in packages/template-compiler/src/binding-command.ts - About 1 hr to fix

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

        export class OneTimeBindingCommand implements BindingCommandInstance {
          public static readonly $au: BindingCommandStaticAuDefinition = {
            type: bindingCommandTypeName,
            name: 'one-time',
          };
        Severity: Major
        Found in packages/template-compiler/src/binding-command.ts and 1 other location - About 1 day to fix
        packages/template-compiler/src/binding-command.ts on lines 230..252

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

        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

        export class ToViewBindingCommand implements BindingCommandInstance {
          public static readonly $au: BindingCommandStaticAuDefinition = {
            type: bindingCommandTypeName,
            name: 'to-view',
          };
        Severity: Major
        Found in packages/template-compiler/src/binding-command.ts and 1 other location - About 1 day to fix
        packages/template-compiler/src/binding-command.ts on lines 205..228

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

        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

        export class FromViewBindingCommand implements BindingCommandInstance {
          public static readonly $au: BindingCommandStaticAuDefinition = {
            type: bindingCommandTypeName,
            name: 'from-view',
          };
        Severity: Major
        Found in packages/template-compiler/src/binding-command.ts and 1 other location - About 1 day to fix
        packages/template-compiler/src/binding-command.ts on lines 278..300

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

        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

        export class TwoWayBindingCommand implements BindingCommandInstance {
          public static readonly $au: BindingCommandStaticAuDefinition = {
            type: bindingCommandTypeName,
            name: 'two-way',
          };
        Severity: Major
        Found in packages/template-compiler/src/binding-command.ts and 1 other location - About 1 day to fix
        packages/template-compiler/src/binding-command.ts on lines 254..276

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

        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

        export class CaptureBindingCommand implements BindingCommandInstance {
          public static readonly $au: BindingCommandStaticAuDefinition = {
            type: bindingCommandTypeName,
            name: 'capture',
          };
        Severity: Major
        Found in packages/template-compiler/src/binding-command.ts and 1 other location - About 4 hrs to fix
        packages/template-compiler/src/binding-command.ts on lines 373..388

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

        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

        export class TriggerBindingCommand implements BindingCommandInstance {
          public static readonly $au: BindingCommandStaticAuDefinition = {
            type: bindingCommandTypeName,
            name: 'trigger',
          };
        Severity: Major
        Found in packages/template-compiler/src/binding-command.ts and 1 other location - About 4 hrs to fix
        packages/template-compiler/src/binding-command.ts on lines 390..405

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

        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

          const getDefinitionFromStaticAu = <Def extends ResourceDefinition, C extends Constructable = Constructable>(
            // eslint-disable-next-line @typescript-eslint/ban-types
            Type: C | Function,
            typeName: string,
            createDef: (au: PartialResourceDefinition<Def>, Type: C) => Def,
        Severity: Major
        Found in packages/template-compiler/src/binding-command.ts and 1 other location - About 3 hrs to fix
        packages/runtime-html/src/resources/resources-shared.ts on lines 12..27

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

        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

        export class ClassBindingCommand implements BindingCommandInstance {
          public static readonly $au: BindingCommandStaticAuDefinition = {
            type: bindingCommandTypeName,
            name: 'class',
          };
        Severity: Major
        Found in packages/template-compiler/src/binding-command.ts and 1 other location - About 3 hrs to fix
        packages/template-compiler/src/binding-command.ts on lines 429..439

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

        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

        export class StyleBindingCommand implements BindingCommandInstance {
          public static readonly $au: BindingCommandStaticAuDefinition = {
            type: bindingCommandTypeName,
            name: 'style',
          };
        Severity: Major
        Found in packages/template-compiler/src/binding-command.ts and 1 other location - About 3 hrs to fix
        packages/template-compiler/src/binding-command.ts on lines 444..454

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

        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

        There are no issues that match your filters.

        Category
        Status