mtrevisan/HunLinter

View on GitHub

Showing 338 of 403 total issues

Avoid too many return statements within this method.
Open

            return FSAMatchResult.AUTOMATON_HAS_PREFIX;

    Avoid too many return statements within this method.
    Open

            return Collections.emptyList();

      Avoid too many return statements within this method.
      Open

              return new FSAMatchResult(FSAMatchResult.PREFIX_MATCH, 0, node);

        Avoid too many return statements within this method.
        Open

                return (startsWithUppercase? Casing.PASCAL_CASE: Casing.CAMEL_CASE);

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              public final LinterException withData(final Object data){
                  this.data = (IndexDataPair.class.isInstance(data)? (IndexDataPair<?>)data: IndexDataPair.of(-1, data));
          
                  return this;
              }
          src/main/java/io/github/mtrevisan/hunlinter/workers/exceptions/LinterWarning.java on lines 66..70

          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 40.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  if(LOGGER.isTraceEnabled())
                      for(int i = 0; i < originators.size(); i ++)
                          LOGGER.trace("Inferred inflection: {}", originators.get(i));
          src/main/java/io/github/mtrevisan/hunlinter/parsers/dictionary/generators/WordGeneratorAffixRules.java on lines 72..74

          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 40.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  if(LOGGER.isTraceEnabled())
                      for(int i = 0; i < inflections.size(); i ++)
                          LOGGER.trace("Inflected word: {}", inflections.get(i));
          src/main/java/io/github/mtrevisan/hunlinter/parsers/dictionary/generators/WordMuncher.java on lines 91..93

          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 40.

          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

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              public final LinterWarning withData(final Object data){
                  this.data = (IndexDataPair.class.isInstance(data)? (IndexDataPair<?>)data: IndexDataPair.of(-1, data));
          
                  return this;
              }
          src/main/java/io/github/mtrevisan/hunlinter/workers/exceptions/LinterException.java on lines 68..72

          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 40.

          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

          Further Reading

          Method expandAndRehash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private void expandAndRehash(){
                  final int[] newHashSet = new int[(hashSet.length << 1)];
                  final int bucketMask = (newHashSet.length - 1);
                  for(final int state : hashSet)
                      if(state > 0){

          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 linearizeAndCalculateOffsets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private int linearizeAndCalculateOffsets(final FSAAbstract fsa, final DynamicIntArray states, final DynamicIntArray linearized,
                      final IntIntMap offsets) throws IOException{
                  final IntSet visited = new IntHashSet();
                  final DynamicIntArray nodes = new DynamicIntArray();
                  linearized.clear();

          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 insertSynonyms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public final DuplicationResult<ThesaurusEntry> insertSynonyms(final String partOfSpeechAndSynonyms,
                      final Predicate<String> duplicatesDiscriminator){
                  final String[] posAndSyns = StringUtils.split(partOfSpeechAndSynonyms, ThesaurusEntry.PART_OF_SPEECH_SEPARATOR, 2);
                  if(posAndSyns.length != 2)
                      throw new LinterException(WRONG_FORMAT, partOfSpeechAndSynonyms);

          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 equals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              @Override
              public final boolean equals(final Object obj){
                  if(this == obj)
                      return true;
                  if(obj == null || getClass() != obj.getClass())

          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 getTwofoldInflections has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private List<Inflection> getTwofoldInflections(final List<Inflection> onefoldInflections, final boolean isCompound,
                      final boolean reverse, final RuleEntry overriddenRule) throws NoApplicableRuleException{
                  final List<Inflection> twofoldInflections = new ArrayList<>(0);
                  for(int i = 0; i < onefoldInflections.size(); i ++){
                      final Inflection inflection = onefoldInflections.get(i);

          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 match has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public final void match(final Inflection inflection){
                  if(!inflection.getContinuationFlags().isEmpty())
                      for(int i = 0; i < wrongFlags.length; i ++)
                          if(inflection.hasContinuationFlag(wrongFlags[i]))
                              throw new LinterException(messagePattern, masterLetter, wrongFlags[i], correctRule);

          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 letterToFlagCompatibilityCheck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public final void letterToFlagCompatibilityCheck(final Inflection inflection){
                  final String word = inflection.getWord();
                  for(int i = 0; i < letterAndRulesCombinableKeys.length; i ++)
                      if(!StringUtils.containsAny(word, letterAndRulesCombinableKeys[i])){
                          final LetterMatcherEntry[] letterMatcherEntries = letterAndRulesCombinable.get(letterAndRulesCombinableKeys[i]);
          Severity: Minor
          Found in src/main/java/io/github/mtrevisan/hunlinter/languages/RulesLoader.java - About 25 mins to fix

          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 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private static void checkCompoundValidity(final String[] parts, final String compoundRule){
                  for(final String part : parts){
                      final boolean isNumber = (part.length() != 1
                          || !FlagParsingStrategy.FLAG_OPTIONAL.equals(part) && !FlagParsingStrategy.FLAG_ANY.equals(part));
                      if(isNumber && !NumberUtils.isCreatable(part))

          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 applyAffixRules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private List<Inflection> applyAffixRules(final DictionaryEntry dicEntry, final RuleEntry overriddenRule,
                      final boolean enforceOnlyInCompound){
                  final List<Inflection> inflections = applyAffixRules(dicEntry, false, overriddenRule);
          
                  if(enforceOnlyInCompound)

          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 withEquivalentChars has a Cognitive Complexity of 6 (exceeds 5 allowed). 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()){

          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 equals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              @Override
              public final boolean equals(final Object obj){
                  if(this == obj)
                      return true;
                  if(obj == null || getClass() != obj.getClass())

          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 withReplacementPairs has a Cognitive Complexity of 6 (exceeds 5 allowed). 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()){

          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

          Severity
          Category
          Status
          Source
          Language