zsarnett/Lit-Grid-Layout

View on GitHub

Showing 25 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

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

                              private _resizeEnd(ev: Event): void {
                                ev.stopPropagation();
                                ev.preventDefault();
                            
                                fireEvent(this, "resizeStart");
                            Severity: Minor
                            Found in src/lit-resizable-wrapper.ts and 1 other location - About 35 mins to fix
                            src/lit-resizable-wrapper.ts on lines 29..34

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

                            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

                              private _resizeStart(ev: Event): void {
                                ev.stopPropagation();
                                ev.preventDefault();
                            
                                fireEvent(this, "resizeStart");
                            Severity: Minor
                            Found in src/lit-resizable-wrapper.ts and 1 other location - About 35 mins to fix
                            src/lit-resizable-wrapper.ts on lines 48..53

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

                            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

                            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
                              Severity
                              Category
                              Status
                              Source
                              Language