zsarnett/Lit-Grid-Layout

View on GitHub

Showing 23 of 25 total issues

File lit-grid-layout.ts has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import deepClone from "deep-clone-simple";
import {
  css,
  CSSResult,
  customElement,
Severity: Minor
Found in src/lit-grid-layout.ts - About 3 hrs to fix

    Consider simplifying this complex logical expression.
    Open

        if (
          changedProps.has("parentWidth") ||
          changedProps.has("margin") ||
          changedProps.has("columns") ||
          changedProps.has("containerPadding") ||
    Severity: Critical
    Found in src/lit-grid-item.ts - About 3 hrs to fix

      File lit-grid-item.ts has 271 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import {
        css,
        CSSResult,
        customElement,
        html,
      Severity: Minor
      Found in src/lit-grid-item.ts - About 2 hrs to fix

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

          protected updated(changedProps: PropertyValues): void {
            // Set up all the calculations that are needed in the drag/resize events
            // No need to calculate them all the time unless they change
            if (
              changedProps.has("parentWidth") ||
        Severity: Major
        Found in src/lit-grid-item.ts - About 2 hrs to fix

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

            protected render(): TemplateResult {
              if (!this._layout?.length || !this.itemRenderer) {
                return html``;
              }
          
          
          Severity: Minor
          Found in src/lit-grid-layout.ts - About 1 hr to fix

            Function render has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              protected render(): TemplateResult {
                let gridItemHTML = html`<slot></slot>`;
            
                if (this.isDraggable) {
                  gridItemHTML = html`
            Severity: Minor
            Found in src/lit-grid-item.ts - About 1 hr to fix

              Function moveItem has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const moveItem = (
                layout: Layout,
                item: LayoutItem,
                newPosX: number | undefined,
                newPosY: number | undefined,
              Severity: Minor
              Found in src/util/move-item.ts - About 1 hr to fix

                Function updated has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  protected updated(changedProps: PropertyValues): void {
                    // Set up all the calculations that are needed in the drag/resize events
                    // No need to calculate them all the time unless they change
                    if (
                      changedProps.has("parentWidth") ||
                Severity: Minor
                Found in src/lit-grid-item.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 styles has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static get styles(): CSSResult {
                    return css`
                      .grid-item-wrapper {
                        position: absolute;
                        transition: var(--grid-item-transition, all 200ms);
                Severity: Minor
                Found in src/lit-grid-item.ts - About 1 hr to fix

                  Function _dragStart has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private _dragStart(ev: MouseEvent | TouchEvent): void {
                      if (
                        (ev.type.startsWith("mouse") && (ev as MouseEvent).button !== 0) ||
                        this.disabled
                      ) {
                  Severity: Minor
                  Found in src/lit-draggable.ts - About 1 hr to fix

                    Function firstUpdated has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      protected firstUpdated(): void {
                        this.addEventListener("mousedown", this._dragStart.bind(this), {
                          capture: true,
                          passive: false,
                        });
                    Severity: Minor
                    Found in src/lit-draggable.ts - About 1 hr to fix

                      Function render has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        protected render(): TemplateResult {
                          return html`
                            <slot></slot>
                      
                            ${this.disabled
                      Severity: Minor
                      Found in src/lit-resizable.ts - About 1 hr to fix

                        Function styles has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          static get styles(): CSSResult {
                            return css`
                              :host {
                                position: relative;
                                display: block;
                        Severity: Minor
                        Found in src/lit-resizable.ts - About 1 hr to fix

                          Function moveItemAwayFromIntersect has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export const moveItemAwayFromIntersect = (
                            layout: Layout,
                            intersectItem: LayoutItem,
                            itemToMove: LayoutItem,
                            cols: number,
                          Severity: Minor
                          Found in src/util/move-item-away-from-intersect.ts - About 1 hr to fix

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

                            export const moveItem = (
                              layout: Layout,
                              item: LayoutItem,
                              newPosX: number | undefined,
                              newPosY: number | undefined,
                            Severity: Minor
                            Found in src/util/move-item.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 _dragStart has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                              private _dragStart(ev: MouseEvent | TouchEvent): void {
                                if (
                                  (ev.type.startsWith("mouse") && (ev as MouseEvent).button !== 0) ||
                                  this.disabled
                                ) {
                            Severity: Minor
                            Found in src/lit-draggable.ts - About 35 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 fixLayoutBounds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export const fixLayoutBounds = (
                              layout: LayoutItem[],
                              cols: number
                            ): LayoutItem[] => {
                              for (const item of layout) {
                            Severity: Minor
                            Found in src/util/fix-layout-bounds.ts - About 35 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

                            Avoid too many return statements within this function.
                            Open

                              return true;
                            Severity: Major
                            Found in src/util/intersects.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return false;
                              Severity: Major
                              Found in src/util/intersects.ts - About 30 mins to fix

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

                                export const resolveIntersection = (
                                  layout: LayoutItem[],
                                  item: LayoutItem,
                                  newYPos: number
                                ): void => {
                                Severity: Minor
                                Found in src/util/resolve-intersection.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

                                Severity
                                Category
                                Status
                                Source
                                Language