Microsoft/fast-dna

View on GitHub

Showing 258 of 12,136 total issues

Function createElementTemplate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function createElementTemplate<TSource = any, TParent = any>(
    tagName: string,
    options?: ElementCreateOptions
): ViewTemplate<TSource, TParent> {
    const markup: Array<string> = [];
Severity: Minor
Found in packages/web-components/fast-element/src/templating/render.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 merge has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function merge(splice: Splice, splices: Splice[]): void {
    let inserted = false;
    let insertionOffset = 0;

    for (let i = 0; i < splices.length; i++) {
Severity: Major
Found in packages/web-components/fast-element/src/observation/arrays.ts - About 2 hrs to fix

    Function convertDocFiles has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function convertDocFiles(dir, docFiles, package, exportPath) {
        for (const docFile of docFiles) {
            try {
                const { name: id, ext } = path.parse(docFile);
                if (ext !== ".md") {
    Severity: Major
    Found in sites/website/src/generate-docs.js - About 2 hrs to fix

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

      export class DefaultRouter implements Router {
          private parentRouter: Router | null | undefined = void 0;
          private contributors = new Set<NavigationContributor>();
      
          private navigationQueue: NavigationQueue | null = null;
      Severity: Minor
      Found in packages/web-components/fast-router/src/router.ts - About 2 hrs to fix

        Function Updates has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const Updates: UpdateQueue = FAST.getById(KernelServiceId.updateQueue, () => {
            const tasks: Callable[] = [];
            const pendingErrors: any[] = [];
            const rAF = globalThis.requestAnimationFrame;
            let updateAsync = true;
        Severity: Major
        Found in packages/web-components/fast-element/src/observation/update-queue.ts - About 2 hrs to fix

          Function getAsync has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public async getAsync<K extends Key>(key: K): Promise<Resolved<K>> {
                  validateKey(key);
          
                  if ((key as Resolver).$isResolver) {
                      return (key as Resolver).resolveAsync(this, this);
          Severity: Minor
          Found in packages/web-components/fast-element/src/di/di.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 getResolver has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public getResolver<K extends Key, T = K>(
                  key: K | Key,
                  autoRegister: boolean = true
              ): Resolver<T> | null {
                  validateKey(key);
          Severity: Minor
          Found in packages/web-components/fast-element/src/di/di.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 updateViews has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private updateViews(splices: Splice[]): void {
                  const views = this.views;
                  const bindView = this.bindView;
                  const items = this.items!;
                  const template = this.template;
          Severity: Major
          Found in packages/web-components/fast-element/src/templating/repeat.ts - About 2 hrs to fix

            Function connect has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public connect() {
                    // Initialize needsHydration on first connect
                    if (this.needsHydration === undefined) {
                        this.needsHydration =
                            this.source.getAttribute(needsHydrationAttribute) !== null;

              Function targetComment has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function targetComment(
                  node: Comment,
                  walker: TreeWalker,
                  factories: CompiledViewBehaviorFactory[],
                  targets: ViewBehaviorTargets,
              Severity: Minor
              Found in packages/web-components/fast-element/src/hydration/target-builder.ts - About 2 hrs to fix

                Function updateContent has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function updateContent(
                    this: HTMLBindingDirective,
                    target: ContentTarget,
                    aspect: string,
                    value: any,

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

                      create<TSource = any, TParent = any>(
                          source: TSource
                      ): ViewBehaviorOrchestrator<TSource, TParent> {
                          const behaviors: ViewBehavior[] = [];
                          const targets: ViewBehaviorTargets = {};
                  Severity: Minor
                  Found in packages/web-components/fast-element/src/utilities.ts - About 2 hrs to fix

                    Function createComplexObject has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function createComplexObject() {
                        return {
                            a: {
                                b: {
                                    c: 1,
                    Severity: Minor
                    Found in packages/web-components/fast-element/src/state/reactive.spec.ts - About 2 hrs to fix

                      Function map has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public map(...routes: MappableRouteDefinition<TSettings>[]) {
                              for (const route of routes) {
                                  if ("children" in route) {
                                      const titleBuilder = this.owner.createTitleBuilder();
                                      const childRoutes = route.children.map(x => {
                      Severity: Minor
                      Found in packages/web-components/fast-router/src/routes.ts - About 1 hr to fix

                        Function getDependencies has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            getDependencies(Type: Constructable | Injectable): Key[] {
                                // Note: Every detail of this getDependencies method is pretty deliberate at the moment,
                                // and probably not yet 100% tested from every possible angle,
                                // so be careful with making changes here as it can have a huge impact on complex end user apps.
                                // Preferably, only make changes to the dependency resolution process via a RFC.
                        Severity: Minor
                        Found in packages/web-components/fast-element/src/di/di.ts - About 1 hr to fix

                          Function fixture has 46 lines of code (exceeds 25 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 1 hr to fix

                            Function createContext has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function createContext<K extends Key>(
                                nameConfigOrCallback?:
                                    | string
                                    | ((builder: ResolverBuilder<K>) => Resolver<K>)
                                    | InterfaceConfiguration,
                            Severity: Minor
                            Found in packages/web-components/fast-element/src/di/di.ts - About 1 hr to fix

                              Function from has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  from<TBase extends typeof HTMLElement>(
                                      BaseType: TBase
                                  ): { new (): InstanceType<TBase> & RouterElement } {
                                      class RouterBase extends (BaseType as any) {
                                          public readonly [routerProperty]!: Router;
                              Severity: Minor
                              Found in packages/web-components/fast-router/src/router.ts - About 1 hr to fix

                                Function run has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public async run(router: Router, message: NavigationMessage) {
                                        const events = router.config!.createEventSink();
                                        const match = await router.config!.recognizeRoute(message.path);
                                
                                        if (match === null) {
                                Severity: Minor
                                Found in packages/web-components/fast-router/src/process.ts - About 1 hr to fix

                                  Function spliceOperationsFromEditDistances has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function spliceOperationsFromEditDistances(distances: number[][]): number[] {
                                      let i = distances.length - 1;
                                      let j = distances[0].length - 1;
                                      let current = distances[i][j];
                                      const edits: number[] = [];
                                  Severity: Minor
                                  Found in packages/web-components/fast-element/src/observation/arrays.ts - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language