Showing 338 of 403 total issues
Method prepareTextForFilter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static Pair<String, String> prepareTextForFilter(final String[] partOfSpeeches, final String[] synonyms){
//extract Part-of-Speech if present
final String posFilter = (partOfSpeeches != null && partOfSpeeches.length > 0
? "[\\(\\s](" + StringUtils.join(partOfSpeeches, PIPE) + ")[\\),]"
: ".+");
- 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 checkCompoundValidity
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static void checkCompoundValidity(final String[] parts, final CharSequence compoundRule){
for(final String part : parts){
final int size = part.length();
final boolean isFlag = (size != 1
|| !FlagParsingStrategy.FLAG_OPTIONAL.equals(part) && !FlagParsingStrategy.FLAG_ANY.equals(part));
- 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 getMinimumFromLength
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public final int getMinimumFromLength(){
int minLength = -1;
for(final String f : from){
final int length = f.length();
if(length < minLength || minLength < 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 freezeState
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private int freezeState(final int activePathIndex){
final int start = activePath[activePathIndex];
final int end = nextArcOffset[activePathIndex];
final int length = end - start;
- 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 add
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public final boolean add(final String[] partOfSpeeches, final String[] synonyms){
final StringJoiner sj = new StringJoiner(LIST_SEPARATOR, PART_OF_SPEECH_START, PART_OF_SPEECH_END);
final int size = (partOfSpeeches != null? partOfSpeeches.length: 0);
for(int i = 0; i < size; i ++)
sj.add(partOfSpeeches[i]);
- 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 contains
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public final boolean contains(final Collection<String> partOfSpeeches, final List<String> synonyms){
final Collection<String> ss = new ArrayList<>(synonyms);
final boolean removed = ss.remove(definition);
if(removed)
for(int i = 0; i < this.synonyms.size(); i ++)
- 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 insertRuleOrUpdateFrom
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static void insertRuleOrUpdateFrom(final List<LineEntry> expandedRules, final LineEntry rule){
final int ruleIndex = expandedRules.indexOf(rule);
if(ruleIndex >= 0)
expandedRules.get(ruleIndex).from.addAll(rule.from);
else{
- 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 containsPartOfSpeechesAndSynonym
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public final boolean containsPartOfSpeechesAndSynonym(final List<String> partOfSpeeches, final String synonym){
if(synonyms != null)
for(int i = 0; i < synonyms.size(); i ++){
final SynonymsEntry entry = synonyms.get(i);
if(entry.hasSamePartOfSpeeches(partOfSpeeches) && entry.containsSynonym(synonym))
- 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 initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
@EventHandler
@SuppressWarnings({"unused", "NumberEquality"})
public final void initialize(final Integer actionCommand){
if(actionCommand != MainFrame.ACTION_COMMAND_INITIALIZE)
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
Method validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public final void validate(){
if(getExpectedNumberOfElements() <= 0)
throw new IllegalArgumentException(INVALID_NUMBER_OF_ELEMENTS);
if(getFalsePositiveProbability() <= 0. || getFalsePositiveProbability() >= 1.)
throw new IllegalArgumentException(INVALID_FALSE_POSITIVE_PROBABILITY);
- 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 contains
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
@Override
public final boolean contains(final T value){
if(value != null)
for(final BloomFilterInterface<T> filter : filters)
if(filter.contains(value))
- 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 validateBasicRules
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static void validateBasicRules(final CharSequence rule){
if(!RegexHelper.find(rule, PATTERN_VALID_RULE))
throw new LinterException(INVALID_RULE, rule);
if(!StringUtils.contains(rule, EQUALS_SIGN)){
if(!RegexHelper.find(rule, PATTERN_VALID_RULE_BREAK_POINTS))
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
private static ByteBuffer clearAndEnsureCapacity(ByteBuffer buffer, final int elements){
if(buffer == null || buffer.capacity() < elements)
buffer = ByteBuffer.allocate(elements);
else
buffer.clear();
- 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 45.
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 siftDown
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static <T> void siftDown(final T[] data, final int low, final int heapsize, final Comparator<? super T> comparator){
//index of the element being moved down the tree
int parent = low;
int leftChild;
do{
- 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 createInnerProcessorByLines
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private Consumer<IndexDataPair<String>> createInnerProcessorByLines(final Consumer<IndexDataPair<String>> dataProcessor,
final long totalEntries){
final AtomicInteger progress = new AtomicInteger(1);
final AtomicInteger progressIndex = new AtomicInteger(1);
final int progressStep = (int)Math.ceil(totalEntries / 100.f);
- 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 getMorphologicalFields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public List<String> getMorphologicalFields(final MorphologicalTag morphologicalTag){
final List<String> collector = new ArrayList<>(morphologicalFields != null? morphologicalFields.size(): 0);
if(morphologicalFields != null){
final String tag = morphologicalTag.getCode();
final int purgeTag = tag.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 encode
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static void encode(final ByteArrayList encodings, final List<Inflection> inflections, final byte separator,
final SequenceEncoderInterface sequenceEncoder){
ByteBuffer tag = ByteBuffer.allocate(0);
for(int i = 0; i < inflections.size(); i ++){
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
private static ByteBuffer clearAndEnsureCapacity(ByteBuffer buffer, final int elements){
if(buffer == null || buffer.capacity() < elements)
buffer = ByteBuffer.allocate(elements);
else
buffer.clear();
- 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 45.
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 extractWords
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private List<String> extractWords(){
final List<String> list = new ArrayList<>(0);
final Charset charset = dicParser.getCharset();
final File dicFile = dicParser.getDicFile();
- 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
private void processThesaurus(final Stream<ThesaurusEntry> entries, final int totalEntries,
final Consumer<ThesaurusEntry> dataProcessor){
try{
final Consumer<ThesaurusEntry> innerProcessor = createInnerProcessor(dataProcessor, totalEntries);
entries.forEach(innerProcessor);
- 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 44.
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