Skip to content
Advertisement

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

JavaScript

Advertisement

Answer

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

JavaScript

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

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement