Showing 958 of 958 total issues
Function updateStateForChar
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private updateStateForChar(
state: State,
index: int,
result: Collection<State>
): void {
- 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
if (codewordsRow < codewords.length - 2) {
otherCodewords[9] = codewords[codewordsRow + 2];
otherCodewords[12] = previousColumnCodewords[codewordsRow + 2];
otherCodewords[13] = nextColumnCodewords[codewordsRow + 2];
}
- 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 76.
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
if (codewordsRow < codewords.length - 1) {
otherCodewords[1] = codewords[codewordsRow + 1];
otherCodewords[6] = previousColumnCodewords[codewordsRow + 1];
otherCodewords[7] = nextColumnCodewords[codewordsRow + 1];
}
- 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 76.
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 encodeChar
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
encodeChar(c: char, sb: StringBuilder): number {
if (c === ' '.charCodeAt(0)) {
sb.append(0o3);
return 1;
}
Function getC40Value
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
getC40Value(c40: boolean, setIndex: number, c: number, fnc1: number): number {
if (c === fnc1) {
if (!(setIndex === 2)) {
throw new Error('FNC1 cannot be used in C40 shift 2');
}
Function calculateBlackPoints
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static calculateBlackPoints(luminances: Uint8ClampedArray,
subWidth: number /*int*/,
subHeight: number /*int*/,
width: number /*int*/,
height: number /*int*/): Int32Array[] {
Consider simplifying this complex logical expression. Open
if (c40) {
return c <= 31
? c
: c === 32
? 3
Consider simplifying this complex logical expression. Open
if (x + 6 < width &&
arrayY[x] === 1 &&
arrayY[x + 1] === 0 &&
arrayY[x + 2] === 1 &&
arrayY[x + 3] === 1 &&
Consider simplifying this complex logical expression. Open
if (y + 6 < height &&
array[y][x] === 1 &&
array[y + 1][x] === 0 &&
array[y + 2][x] === 1 &&
array[y + 3][x] === 1 &&
Function encode
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static encode(content: string,
ecLevel: ErrorCorrectionLevel,
hints: Map<EncodeHintType, any> = null): QRCode /*throws WriterException*/ {
// Determine what character encoding has been specified by the caller, if any
Function setHints
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public setHints(hints?: Map<DecodeHintType, any> | null): void {
this.hints = hints;
const tryHarder: boolean = hints !== null && hints !== undefined && undefined !== hints.get(DecodeHintType.TRY_HARDER);
/*@SuppressWarnings("unchecked")*/
Function parseFromString
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static parseFromString(stringRepresentation: string, setString: string, unsetString: string): BitMatrix {
if (stringRepresentation === null) {
throw new IllegalArgumentException('stringRepresentation cannot be null');
}
Function constructor
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(stringToEncode: string, priorityCharset: Charset, fnc1: number) {
const neededEncoders: CharsetEncoder[] = [];
// we always need the ISO-8859-1 encoder. It is the default encoding
neededEncoders.push(new CharsetEncoder(StandardCharsets.ISO_8859_1));
Function getEncodedData
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static getEncodedData(correctedBits: boolean[]): string {
let endIndex: number = correctedBits.length;
let latchTable = Table.UPPER; // table most recently latched to
let shiftTable = Table.UPPER; // table to use for the next read
let result: string = '';
Function extractPureBits
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static extractPureBits(image: BitMatrix): BitMatrix /*throws NotFoundException */ {
const leftTopBlack: Int32Array = image.getTopLeftOnBit();
const rightBottomBlack: Int32Array = image.getBottomRightOnBit();
if (leftTopBlack === null || rightBottomBlack === null) {
Function findRowsWithPattern
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static findRowsWithPattern( matrix: BitMatrix,
height: /*int*/ number,
width: /*int*/ number,
startRow: /*int*/ number,
startColumn: /*int*/ number,
Function parseFieldsInGeneralPurpose
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
static parseFieldsInGeneralPurpose(rawInformation: string): string {
if (!rawInformation) {
return null;
}
Function doDecode
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private doDecode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result {
const width = image.getWidth();
const height = image.getHeight();
let row = new BitArray(width);
Function decodeEdifactSegment
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private static decodeEdifactSegment(bits: BitSource, result: StringBuilder): void {
do {
// If there is only two or less bytes left then it will be encoded as ASCII
if (bits.available() <= 16) {
return;
- 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 decodeNumericSegment
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private static decodeNumericSegment(bits: BitSource,
result: StringBuilder,
count: number /*int*/): void /*throws FormatException*/ {
// Read three digits at a time
while (count >= 3) {
- 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"