src/lit-grid-item.ts
Consider simplifying this complex logical expression. Open
Open
if (
changedProps.has("parentWidth") ||
changedProps.has("margin") ||
changedProps.has("columns") ||
changedProps.has("containerPadding") ||
File lit-grid-item.ts
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import {
css,
CSSResult,
customElement,
html,
Function updated
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
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") ||
Function render
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected render(): TemplateResult {
let gridItemHTML = html`<slot></slot>`;
if (this.isDraggable) {
gridItemHTML = html`
Function updated
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
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") ||
- Read upRead up
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
Open
static get styles(): CSSResult {
return css`
.grid-item-wrapper {
position: absolute;
transition: var(--grid-item-transition, all 200ms);