Microsoft/fast-dna

View on GitHub

Showing 231 of 12,131 total issues

Function traverse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function traverse(node: DefaultTreeNode | DefaultTreeParentNode, visitor: Visitor) {
    // Templates parsed with `parse()` are parsed as full documents and will contain
    // html, body tags whether the template contains them or not. Skip over visiting and
    // leaving these elements if there is no source-code location, because that indicates
    // they are not in the template string.

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 inject has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    inject(
        ...dependencies: Key[]
    ): (
        target: any,
        key?: string | number,
Severity: Minor
Found in packages/web-components/fast-element/src/di/di.ts - About 1 hr to fix

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

    function create(options: any): RenderInstruction {
        const name = options.name ?? defaultViewName;
        let template: ContentTemplate;
    
        if (isElementRenderOptions(options)) {
    Severity: Minor
    Found in packages/web-components/fast-element/src/templating/render.ts - About 1 hr to fix

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

          public constructor(element: TElement, definition: FASTElementDefinition) {
              super(element);
      
              this.source = element;
              this.definition = definition;

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

        function updateTokenList(
            this: HTMLBindingDirective,
            target: Element,
            aspect: string,
            value: any

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

              private addTargetDescriptor(
                  parentId: string,
                  targetId: string,
                  targetIndex: number
              ): void {
          Severity: Minor
          Found in packages/web-components/fast-element/src/templating/compiler.ts - About 1 hr to fix

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

            function buildParam(key: string, value: any, traditional?: boolean): Array<string> {
                let result: string[] = [];
            
                if (value === null || value === undefined) {
                    return result;
            Severity: Minor
            Found in packages/web-components/fast-router/src/query-string.ts - About 1 hr to fix

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

                  private refreshView() {
                      let view = this.view;
                      const template = this.template;
              
                      if (view === null) {
              Severity: Minor
              Found in packages/web-components/fast-element/src/templating/render.ts - About 1 hr to fix

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

                            get: function (this: any) {
                                let value = this[field];
                
                                if (value === void 0) {
                                    const container: Container =
                Severity: Minor
                Found in packages/web-components/fast-element/src/di/di.ts - About 1 hr to fix

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

                      public resolveAsync(handler: Container, requestor: Container) {
                          switch (this.strategy) {
                              case ResolverStrategy.singleton: {
                                  if (this.resolving) {
                                      throw FAST.error(Message.cyclicDependency, { name: this.state.name });
                  Severity: Minor
                  Found in packages/web-components/fast-element/src/di/di.ts - About 1 hr to fix

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

                        public bind(source: TSource, context: ExecutionContext<TParent> = this): void {
                            if (this.source === source) {
                                return;
                            }
                    
                    
                    Severity: Minor
                    Found in packages/web-components/fast-element/src/templating/view.ts - About 1 hr to fix

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

                          bind(controller: ViewController): void {
                              const target = controller.targets[this.targetNodeId];
                      
                              switch (this.aspectType) {
                                  case DOMAspect.event:

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

                            private getEventInfo(event: MouseEvent): AnchorEventInfo {
                                const info: AnchorEventInfo = {
                                    shouldHandleEvent: false,
                                    href: null,
                                    anchor: null,
                        Severity: Minor
                        Found in packages/web-components/fast-router/src/links.ts - About 1 hr to fix

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

                              public constructor(
                                  public readonly prevState: AnyState<T> | null,
                                  public readonly segment: AnySegment<T> | null,
                                  public readonly value: string
                              ) {
                          Severity: Minor
                          Found in packages/web-components/fast-router/src/recognizer.ts - About 1 hr to fix

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

                                assignAspect(directive: Aspected, value?: string): void {
                                    if (!value) {
                                        directive.aspectType = DOMAspect.content;
                                        return;
                                    }

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

                                  public async recognize(path: string): Promise<RouteMatch<TSettings> | null> {
                                      const result = await this.recognizer.recognize(path, this.aggregateConverters());
                              
                                      if (result !== null) {
                                          return {
                              Severity: Minor
                              Found in packages/web-components/fast-router/src/routes.ts - About 1 hr to fix

                                Function refreshView has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    private refreshView() {
                                        let view = this.view;
                                        const template = this.template;
                                
                                        if (view === null) {
                                Severity: Minor
                                Found in packages/web-components/fast-element/src/templating/render.ts - About 55 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 fixture has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export async function fixture<TElement = HTMLElement>(
                                    templateNameOrType: ViewTemplate | string | Constructable<TElement>,
                                    options: FixtureOptions = {}
                                ): Promise<Fixture<TElement>> {
                                    const document = options.document || globalThis.document;
                                Severity: Minor
                                Found in packages/web-components/fast-element/src/testing/fixture.ts - About 55 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 bind has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    public bind(source: TSource, context: ExecutionContext<TParent> = this): void {
                                        if (this.source === source) {
                                            return;
                                        }
                                
                                
                                Severity: Minor
                                Found in packages/web-components/fast-element/src/templating/view.ts - About 55 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 elementChanged has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    elementChanged() {
                                        if (this.element) {
                                            const dispatch = this.element.dispatchEvent;
                                            Reflect.defineProperty(this.element, "dispatchEvent", {
                                                value: (event: Event) => {

                                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