Skip to content

Getting sonarlint rule error: no magic number: 1.5. Added the code below

//In here i am multiplying 1.5 with diameter and my sonarlint plugin is showing above mentioned //error

  & + span {
      position: relative;
      display: inline-block;
      user-select: none;
      transition: 0.4s ease;
      height: ${({ diameter }) => diameter}px;
      width: ${({ diameter }) => Math.round(1.5 * diameter)}px;



I am going to ask the same question your linter has. What is 1.5 used for ? No magic Numbers in other words is don’t hard code numbers, if it is a constant then create it

const circ = 3.1416 * (RADIUS*RADIUS);

3.1416 is a magic number, to fix that you need to add its constant

 const PI = 3.1416;

const circ = PI * (RADIUS*RADIUS);
User contributions licensed under: CC BY-SA
1 People found this is helpful