src/modules/NoiseReduction/NoiseReduction.js
Function Noise
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = function Noise(pixels, method) {
let neighbourX = [-1, -1, -1, 0, 0, 0, 1, 1, 1];
let neighbourY = [-1, 0, 1, -1, 0, 1, -1, 0, 1];
if(method == 'Median Filtering'){
- Read upRead up
- Create a ticketCreate a ticket
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 Noise
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function Noise(pixels, method) {
let neighbourX = [-1, -1, -1, 0, 0, 0, 1, 1, 1];
let neighbourY = [-1, 0, 1, -1, 0, 1, -1, 0, 1];
if(method == 'Median Filtering'){
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
while( k <= 8){
let newX = x + neighbourX[k], newY = y + neighbourY[k];
if( newX >= 0 && newX < pixels.shape[0])
{
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if( newX >= 0 && newX < pixels.shape[0])
{
if( newY >= 0 && newY < pixels.shape[1]){
windowr[i] = pixels.get((newX), (newY), 0);
windowg[i] = pixels.get((newX), (newY), 1);
- Create a ticketCreate a ticket