Microsoft/fast-dna

View on GitHub

Showing 426 of 3,050 total issues

Avoid too many return statements within this function.
Open

                return -1;
Severity: Major
Found in packages/web-components/fast-router/src/recognizer.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return 0;
    Severity: Major
    Found in packages/web-components/fast-router/src/recognizer.ts - About 30 mins to fix

      Function setTokenValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public setTokenValue<T>(token: DesignToken<T>, value: DesignTokenValue<T>) {
              const changeType =
                  DesignTokenNode.isAssigned(this, token) ||
                  DesignTokenNode.isDerivedFor(this, token)
                      ? DesignTokenMutationType.change

      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 setDefaultSelectedOption has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public setDefaultSelectedOption(): void {
              if (this.$fastController.isConnected && this.options) {
                  const selectedIndex = this.options.findIndex(
                      el => el.getAttribute("selected") !== null || el.selected
                  );
      Severity: Minor
      Found in packages/web-components/fast-foundation/src/combobox/combobox.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

      Function clickHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public clickHandler(e: MouseEvent): boolean | void {
              // do nothing if the select is disabled
              if (this.disabled) {
                  return;
              }
      Severity: Minor
      Found in packages/web-components/fast-foundation/src/select/select.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

      Function selectAllRows has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private selectAllRows(): void {
              if (
                  this.selectionMode !== DataGridSelectionMode.multiRow ||
                  this.rowElements.length === 0
              ) {
      Severity: Minor
      Found in packages/web-components/fast-foundation/src/data-grid/data-grid.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

      Function value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public set value(next: string) {
              const prev = `${this._value}`;
      
              if (this.$fastController.isConnected && this.options) {
                  const selectedIndex = this.options.findIndex(
      Severity: Minor
      Found in packages/web-components/fast-foundation/src/combobox/combobox.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

      Function notifyChildren has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private notifyChildren(...records: DesignTokenChangeRecordImpl<any>[]) {
              if (this.children.length) {
                  for (let i = 0, l = this.children.length; i < l; i++) {
                      for (let j = 0; j < records.length; j++) {
                          this.children[i].dispatch(records[j]);

      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 keyupHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public keyupHandler(e: Event & KeyboardEvent) {
              if (!this.hiddenFromAT) {
                  const key = e.key;
      
                  if (key === "Enter" || key === "Space") {
      Severity: Minor
      Found in packages/web-components/fast-foundation/src/flipper/flipper.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

      Function findFiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function findFiles(startPath, filter, paths = []) {
          if (!fs.existsSync(startPath)) {
              console.log("no dir ", startPath);
              return;
          }
      Severity: Minor
      Found in sites/website/src/generate-docs.js - 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

      Function setThumbPositionForOrientation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private setThumbPositionForOrientation(direction: Direction): void {
              const newPct: number = convertPixelToPercent(
                  Number(this.value),
                  Number(this.min),
                  Number(this.max),
      Severity: Minor
      Found in packages/web-components/fast-foundation/src/slider/slider.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

      Function autoUpdateModeChanged has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          protected autoUpdateModeChanged(
              prevMode: AutoUpdateMode,
              newMode: AutoUpdateMode
          ): void {
              if (this.$fastController.isConnected && this.initialLayoutComplete) {

      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 evaluate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public evaluate(node: DesignTokenNode, tokenContext: DesignToken<any>): T {
              const resolve = <T>(token: DesignToken<T>): T => {
                  this.dependencies.add(token);
                  if (tokenContext === token) {
                      if (node.parent) {

      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 checkMaxItems has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private checkMaxItems(): void {
              if (this.inputElement === undefined) {
                  return;
              }
              if (
      Severity: Minor
      Found in packages/web-components/fast-foundation/src/picker/picker.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

      Function normalize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public static normalize(
              styles: ComposableStyles | ComposableStyles[] | undefined
          ): ElementStyles | undefined {
              return styles === void 0
                  ? void 0
      Severity: Minor
      Found in packages/web-components/fast-element/src/styles/element-styles.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

      Function typeaheadBufferChanged has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public typeaheadBufferChanged(prev: string, next: string): void {
              if (this.$fastController.isConnected) {
                  const typeaheadMatches = this.getTypeaheadMatches();
      
                  if (typeaheadMatches.length) {
      Severity: Minor
      Found in packages/web-components/fast-foundation/src/listbox/listbox.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

      Function installDOMShim has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          installDOMShim(): void {
              for (const key of perRequestGlobals) {
                  if (!shimIsInstalledFor(key)) {
                      const preShimValue = (globalThis as any)[key];
                      preShimGlobals.set(key, (globalThis as any)[key]);
      Severity: Minor
      Found in packages/web-components/fast-ssr/src/request-storage.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

      Function toggle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public toggle(token: string, force: boolean): boolean {
              const result = this.contains(token);
              const method = result ? force !== true && "remove" : force !== false && "add";
      
              if (method) {
      Severity: Minor
      Found in packages/web-components/fast-ssr/src/dom-shim.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

      Function create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          create<T = unknown>(name: string, initialValue?: T): FASTContext<T> {
              const Interface = function (
                  target: Constructable<Node>,
                  property: string,
                  index: number
      Severity: Minor
      Found in packages/web-components/fast-element/src/context.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

      Function addBehavior has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public addBehavior(behavior: HostBehavior<TElement>) {
              const targetBehaviors = this.behaviors ?? (this.behaviors = new Map());
              const count = targetBehaviors.get(behavior) ?? 0;
      
              if (count === 0) {

      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