Showing 338 of 403 total issues
Method makeAdditionsDisjoint
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static List<LineEntry> makeAdditionsDisjoint(final List<LineEntry> rules){
//transform
// [rem=èra,add=[ereta, ara, era, iera, ièra, areta, iereta],cond=èra,from=…]
// [rem=èra,add=[ereta, ara, era, areta],cond=èra,from=…]
//into
- 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
Method linearize
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static int[] linearize(final FSAAbstract fsa){
int[] linearized = new int[0];
int last = 0;
final BitSet visited = new BitSet();
- 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
Method composeCompound
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private List<DictionaryEntry> composeCompound(final int[] indexes, final List<List<Inflection>> entry, final StringBuffer sb){
final String forbiddenWordFlag = affixData.getForbiddenWordFlag();
final boolean forbidDifferentCasesInCompound = affixData.isForbidDifferentCasesInCompound();
final boolean forbidTriples = affixData.isForbidTriplesInCompound();
final boolean simplifyTriples = affixData.isSimplifyTriplesInCompound();
- 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
Method reduceGeminates
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static String reduceGeminates(final CharSequence word){
final StringBuilder sb = new StringBuilder(word);
for(int i = 1; i < sb.length(); i ++){
char chr = sb.charAt(i);
if(chr == sb.charAt(i - 1) && Arrays.binarySearch(WordVEC.VOWELS_ARRAY, chr) < 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
Method getLastUnstressedVowelIndex
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static int getLastUnstressedVowelIndex(final CharSequence word, int lastLetterIndex){
for(lastLetterIndex --; lastLetterIndex >= 0; lastLetterIndex --){
final char chr = word.charAt(lastLetterIndex);
if(Arrays.binarySearch(VOWELS_PLAIN_ARRAY, chr) >= 0){
if(chr != 'i' && chr != 'u')
- 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
Method lookup
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public final List<WordData> lookup(String word){
final byte separator = dictionary.metadata.getSeparator();
if(!dictionary.metadata.getInputConversionPairs().isEmpty())
word = applyReplacements(word, dictionary.metadata.getInputConversionPairs());
- 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
Method collectDuplicates
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private BloomFilterInterface<String> collectDuplicates(){
final File dicFile = dicParser.getDicFile();
final Charset charset = dicParser.getCharset();
final BloomFilterInterface<String> bloomFilter = new ScalableInMemoryBloomFilter<>(charset, dictionaryBaseData);
- 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
Method calculateInflections
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private void calculateInflections(){
final String language = parserManager.getLanguage();
final String text = inputTextField.getText().trim();
if(text.equals(formerInputText))
- 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
Method exactMatchSearch
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private int exactMatchSearch(final String key, final int position, int length, int nodeId){
Objects.requireNonNull(key, "Key cannot be null");
int result = -1;
if(isInitialized()){
- 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
Method serialize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
@Override
public final <T extends OutputStream> T serialize(final FSAAbstract fsa, final T os, final ProgressCallback progressCallback)
throws IOException{
//prepare space for arc offsets and linearize all the states
final int[] linearized = linearize(fsa);
- 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
Method buildMaxHeap
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private static <T> void buildMaxHeap(final T[] data, final int low, final int high, final Comparator<? super T> comparator,
final int progressStep, final ProgressCallback progressCallback){
int progress = 0;
for(int heapsize = low + 1; heapsize < high; heapsize ++){
//if child is bigger than parent
- 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
public final DictionaryMetadataBuilder withReplacementPairs(final Map<String, List<String>> replacementPairs){
final StringBuilder builder = new StringBuilder();
for(final Map.Entry<String, List<String>> e : replacementPairs.entrySet()){
final String k = e.getKey();
for(final String v : e.getValue()){
- 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 98.
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
public final DictionaryMetadataBuilder withEquivalentChars(final Map<Character, List<Character>> equivalentChars){
final StringBuilder builder = new StringBuilder();
for(final Map.Entry<Character, List<Character>> e : equivalentChars.entrySet()){
final Character k = e.getKey();
for(final Character v : e.getValue()){
- 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 98.
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
Method match
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public FSAMatchResult match(final byte[] sequence, final int start, final int length, int node){
if(node == 0)
return new FSAMatchResult(FSAMatchResult.NO_MATCH, start, 0);
final int end = start + length;
- 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
Method emitNodeArcs
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private int emitNodeArcs(final FSAAbstract fsa, final OutputStream os, final int state, final int nextState) throws IOException{
int offset = 0;
for(int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc)){
final boolean arcTerminal = fsa.isArcTerminal(arc);
final int target = (arcTerminal? 0: fsa.getEndNode(arc));
- 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
Method checkReductionCorrectness
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public final void checkReductionCorrectness(final String flag, final List<String> reducedRules, final List<String> originalLines,
final ProgressCallback progressCallback){
final RuleEntry ruleToBeReduced = affixData.getData(flag);
if(ruleToBeReduced == null)
throw new LinterException(NON_EXISTENT_RULE, flag);
- 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
Method parse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
@Override
public final int parse(final ParsingContext context, final AffixData affixData) throws EOFException{
final FlagParsingStrategy strategy = affixData.getFlagParsingStrategy();
final int numEntries = checkValidity(context);
- 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
Method computeInLinkCount
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static IntIntMap computeInLinkCount(final FSAAbstract fsa){
final IntIntMap inLinkCount = new IntIntHashMap();
final IntSet visited = new IntHashSet();
final DynamicIntArray nodes = new DynamicIntArray();
nodes.push(fsa.getRootNode());
- 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
Method computeFirstStates
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static int[] computeFirstStates(final Iterable<IntIntCursor> inLinkCount, final int maxStates, final int minInLinkCount){
final PriorityQueue<IntIntHolder> stateInLink = new PriorityQueue<>(1, COMPARATOR);
final IntIntHolder scratch = new IntIntHolder();
for(final IntIntCursor c : inLinkCount)
if(c.value > minInLinkCount){
- 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
@SuppressWarnings("ConstantConditions")
public SelectFontAction(final Packager packager, final ParserManager parserManager, final Preferences preferences){
super("system.font", new ImageIcon(SelectFontAction.class.getResource("/file_font.png")));
Objects.requireNonNull(packager, "Packager cannot be null");
- 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 86.
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