mtrevisan/HunLinter

View on GitHub

Showing 338 of 403 total issues

Method next has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public final WordData next(){
        final ByteBuffer entryBuffer = entriesItr.next();
        final byte[] array = entryBuffer.array();
        final int limit = entryBuffer.remaining();

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

    @Override
    public final Hyphenation hyphenate(final String word){
        //apply first level hyphenation
        final Map<HyphenationParser.Level, AhoCorasickTrie<String>> patterns = hypParser.getPatterns();
        HyphenationOptions options = hypParser.getOptions().getNonCompoundOptions();

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 8 (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{
        //calculate the most frequent labels and build indexed labels dictionary
        computeLabelsIndex(fsa);

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 deeply nested control flow statements.
Open

                        for(int j = 1; !restart && j < branchSize; j ++){
                            final LineEntry child = branch.get(j);
                            if(!parent.from.containsAll(child.from))
                                //TODO
                                throw new IllegalStateException("No proper children found, please report this case to the developer, thank you");

    Avoid deeply nested control flow statements.
    Open

                            if(inflections.size() > limit)
                                break;

      Method enforceNoHyphens has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public final void enforceNoHyphens(final List<String> syllabes, final Iterable<String> noHyphen){
              if(syllabes.size() > 1){
                  int wordLength = 0;
                  for(int i = 0; i < syllabes.size(); i ++)
                      wordLength += syllabes.get(i).length();

      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 deeply nested control flow statements.
      Open

                                  for(final AffixEntry candidateAppliedRule : candidate.getInflection().getAppliedRules())
                                      candidateAppliedRules.remove(candidateAppliedRule.getFlag());

        Method maxRepeating has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static int maxRepeating(final CharSequence text, final char chr){
                final int n = text.length();
                int count = 0;
                int currentCount = 1;
                //traverse string except last character

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

            @SuppressWarnings("OverlyBroadThrowsClause")
            private static List<File> splitAndSortFiles(final File file, final ExternalSorterOptions options) throws IOException{
                //extract uncompressed file size
                final long dataLength = FileHelper.getFileSize(file);
                final long availableMemory = JavaHelper.estimateAvailableMemory();

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

            private void notifyListeners(final WatchKey key){
                final List<WatchEvent<?>> pollEvents = key.pollEvents();
                for(final WatchEvent<?> event : pollEvents){
                    final WatchEvent.Kind<?> eventKind = event.kind();
        
        

        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 deeply nested control flow statements.
        Open

                                    for(final AffixEntry otherAppliedRule : other.getInflection().getAppliedRules())
                                        otherAppliedRules.remove(otherAppliedRule.getFlag());

          Avoid deeply nested control flow statements.
          Open

                                      if(candidateAppliedRules.isEmpty()){
                                          final String info = candidate.getWord()
                                              + (equalProduction && ! other.getWord().equals(candidate.getWord())? " (or " + other.getWord() + ")": "")
                                              + " is a candidate for removal";
                                          if(!sj.toString().endsWith(info))

            Method append has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                @Override
                protected final void append(final ILoggingEvent eventObject){
                    if((!TEXT_AREAS.isEmpty() || !TEXT_PANES.isEmpty() || !LABELS.isEmpty()) && encoder != null){
                        final Level level = eventObject.getLevel();
                        if(level == Level.WARN && !preferences.getBoolean(ReportWarningsAction.REPORT_WARNINGS, true))

            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 6 arguments (exceeds 4 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){

              Method forEachDictionaryLine has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static void forEachDictionaryLine(final File file, final Charset charset, final BiConsumer<Integer, String> fun,
                          final ProgressCallback progressCallback){
                      final int totalLines = FileHelper.getLinesCount(file, charset);
                      int progress = 0;
                      int progressIndex = 0;
              Severity: Minor
              Found in src/main/java/io/github/mtrevisan/hunlinter/services/ParserHelper.java - About 45 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 mergeSortedFiles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  @SuppressWarnings("OverlyBroadThrowsClause")
                  private static void mergeSortedFiles(final Collection<File> files, final ExternalSorterOptions options, final File outputFile)
                          throws IOException{
                      final Comparator<String> comparator = options.getComparator();
                      final Queue<BinaryFileBuffer> queue = new PriorityQueue<>(files.size(),

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

                  private static String readHunspellCharsetName(final BufferedReader reader, final int limitLinesRead) throws IOException{
                      //scan each lines until either a valid charset name is found as the first line (hyphenation or thesaurus file),
                      //or `SET <charsetName>` is found (affix file)
                      int linesRead = 0;
                      while(limitLinesRead < 0 || linesRead < limitLinesRead){

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

                  private boolean loadHandlerIntoQueue(final Object subscriber){
                      boolean subscribedAlready = false;
                      for(final HandlerInfo info : handlers){
                          final Object otherSubscriber = info.getSubscriber();
                          if(otherSubscriber == null){

              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

                      for(int i = 0; i < text.length(); i ++){
                          final char chr = text.charAt(i);
                          if(Character.isLetter(chr) || Character.isDigit(chr))
                              return true;
                      }
              src/main/java/io/github/mtrevisan/hunlinter/parsers/thesaurus/ThesaurusEntry.java on lines 119..123

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

              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

                          for(int i = 0; i < synonyms.size(); i ++){
                              final SynonymsEntry entry = synonyms.get(i);
                              if(entry.hasSamePartOfSpeeches(partOfSpeeches) && entry.containsSynonym(synonym))
                                  return true;
                          }
              src/main/java/io/github/mtrevisan/hunlinter/services/text/StringHelper.java on lines 62..66

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

              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

              Severity
              Category
              Status
              Source
              Language