mtrevisan/HunLinter

View on GitHub

Showing 197 of 403 total issues

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 ++){

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 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();

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 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{

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

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);

          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

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

              private void enforceCircumfix(final Iterable<Inflection> inflections){
                  final String circumfixFlag = affixData.getCircumfixFlag();
                  if(circumfixFlag != null){
                      final Iterator<Inflection> itr = inflections.iterator();
                      while(itr.hasNext()){

          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