zsarnett/Lit-Grid-Layout

View on GitHub
src/lit-grid-item.ts

Summary

Maintainability
C
1 day
Test Coverage

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

            There are no issues that match your filters.

            Category
            Status