Showing 71 of 71 total issues
Function convolve1D
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function convolve1D(
dstBuffer: ThAWImageBufferType,
dstInitialOffset: number,
numDstPixels: number,
dstPixelStride: number,
- 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 compositeImageFromBuffers
has 15 arguments (exceeds 4 allowed). Consider refactoring. Open
dstBuffer: ThAWImageBufferType,
dstWidth: number,
dstHeight: number,
dstInitialRowOffset: number,
dstRowStride: number,
Function dispatchResample
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function dispatchResample(argv: string[]): Promise<void> {
let srcFilePath = defaultSrcFilePath;
let dstFilePath = `test/output-files/resample.${dstFileExtension}`;
let dstWidth = 0;
let dstHeight = 0;
Function compositeImageFromBuffers
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function compositeImageFromBuffers(
dstBuffer: ThAWImageBufferType,
dstWidth: number,
dstHeight: number,
dstInitialRowOffset: number,
Function generateKernel
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function generateKernel(sigma: number, kernelSize: number): number[] {
// sigma must be a positive number.
// kernelSize must be an odd positive integer smaller than 999.
const sampleCount = 1000.0;
Function convolveImageFromBuffer
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function convolveImageFromBuffer(
srcImage: IThAWImage,
kernel: number[]
// sigma: number,
// kernelSize: number /*, fnCreateImage */
Function dispatch
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function dispatch(argv: string[]): Promise<void> {
const command = argv.shift();
switch (command) {
case 'c':
Function dispatchPixelate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
async function dispatchPixelate(argv: string[]): Promise<void> {
let srcFilePath = defaultSrcFilePath;
let dstFilePath = `test/output-files/pixelate.${dstFileExtension}`;
let pixelWidth = 8;
let pixelHeight = 8;
- 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 doAffineTransformation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export function doAffineTransformation(
dstImage: IThAWImage,
srcImage: IThAWImage,
matrix: IAffineTransformationMatrix,
dstLeft?: number,
- 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 dispatchGaussianBlur
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
async function dispatchGaussianBlur(argv: string[]): Promise<void> {
let srcFilePath = defaultSrcFilePath;
let dstFilePath = `test/output-files/gaussian-blur.${dstFileExtension}`;
// let sigma = 1.0;
let sigma = 4.0;
- 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 resampleImage
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function resampleImage(
srcImage: IThAWImage,
dstWidth: number,
dstHeight: number,
mode: number
Function mapImageByCoordinatesFromBuffer
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
dstBuffer: ThAWImageBufferType,
dstWidth: number,
dstHeight: number,
dstInitialRowOffset: number,
dstRowStride: number,
Function convolve1D
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
dstBuffer: ThAWImageBufferType,
dstInitialOffset: number,
numDstPixels: number,
dstPixelStride: number,
srcBuffer: ThAWImageBufferType,
Function compositeTest
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function compositeTest(srcImage: IThAWImage): IThAWImage {
// const dstImage = generateTestImage_RedGreenGradient(srcImage.width, srcImage.height, fnCreateImage);
const red = 255;
const green = 0;
Function fill
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public fill(
dstRow: number,
dstColumn: number,
width: number,
height: number,
Function fill
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public fill(
dstRow: number,
dstColumn: number,
width: number,
height: number,
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
export function desaturateImage(srcImage: IThAWImage): IThAWImage {
if (srcImage.colourModel !== ColourModel.RGBA32) {
throw new Error('desaturateImage: Unsupported colour model');
}
return mapColoursInImageFromBuffer(srcImage, desaturateRGBA);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
export function rotateColourChannelsInImage(
srcImage: IThAWImage
): IThAWImage {
if (srcImage.colourModel !== ColourModel.RGBA32) {
throw new Error(
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function resample1DNearestNeighbour
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
dstBuffer: ThAWImageBufferType,
dstInitialOffset: number,
numDstPixels: number,
dstPixelStride: number,
srcBuffer: ThAWImageBufferType,
Function resample1DBicubic
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
dstBuffer: ThAWImageBufferType,
dstInitialOffset: number,
numDstPixels: number,
dstPixelStride: number,
srcBuffer: ThAWImageBufferType,