mtrevisan/HunLinter

View on GitHub

Showing 197 of 403 total issues

Method processSentence has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private void processSentence(){
        if(wordTokenizer == null){
            final AffixData affixData = parserManager.getAffixData();
            wordTokenizer = BaseBuilder.getWordTokenizer(affixData.getLanguage());
            charset = affixData.getCharset();

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

    private void grow(){
        IntBlock lastDataBlock = blocks[indexOfLastDataBlock];

        //if the last Block is full, we need to make a new Block
        if(lastDataBlock.isFull()){

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

    private void hyphenateAddRule(){
        final String language = parserManager.getLanguage();
        final Orthography orthography = BaseBuilder.getOrthography(language);
        String addedRuleText = orthography.correctOrthography(wordTextField.getText());
        final String addedRule = orthography.correctOrthography(addRuleTextField.getText().toLowerCase(Locale.ROOT));

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

    private boolean searchInText(final String text, final HitConsumer hitConsumer){
        Objects.requireNonNull(text, "Text cannot be null");

        boolean found = false;
        if(isInitialized()){

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

    public final synchronized void remove(){
        final IntBlock lastNonEmptyDataBlock = blocks[indexOfLastNonEmptyDataBlock];
        lastNonEmptyDataBlock.shrink();
        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 morphologicalFieldCheck has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private void morphologicalFieldCheck(final Inflection inflection, final int index){
        if(!inflection.hasMorphologicalFields())
            EventBusService.publish(new LinterWarning(NO_MORPHOLOGICAL_FIELD, inflection.getWord())
                .withIndex(index));

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

    public final List<String> combineMorphologicalFields(final DictionaryEntry dicEntry){
        final List<String> baseMorphFields = (dicEntry.morphologicalFields != null? new ArrayList<>(dicEntry.morphologicalFields):
            new ArrayList<>(0));
        final List<String> ruleMorphFields = (morphologicalFields != null? morphologicalFields: new ArrayList<>(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 sort has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static <T> void sort(final T[] data, final int low, final int high, final Comparator<? super T> comparator,
            final ProgressCallback progressCallback){
        Objects.requireNonNull(data, "Data cannot be null");
        Objects.requireNonNull(comparator, "Comparator cannot be null");
        assert low < high && low < data.length && high <= data.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

Method compactInflections has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private static LineEntry compactInflections(final List<LineEntry> rules){
        if(rules.size() > 1){
            //retrieve rule with the longest condition (all the other conditions must be this long)
            LineEntry maxConditionEntry = null;
            int maxConditionLength = 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 emitArc has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private int emitArc(final OutputStream os, final int flags, final byte label, final int targetOffset) throws IOException{
        int length = 0;

        final int labelIndex = invertedLabelsIndex[label & 0xFF];
        if(labelIndex > 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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public final void parse(final ParsingContext context) throws EOFException{
        final Scanner scanner = context.getScanner();
        if(!NumberUtils.isCreatable(context.getFirstParameter()))
            throw new LinterException(BAD_FIRST_PARAMETER, context);
        final int numEntries = Integer.parseInt(context.getFirstParameter());

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

    private static List<String> retrieveAdditionsToBeRemoved(final Collection<LineEntry> rules, final LineEntry rule,
            final Collection<LineEntry> temporaryRules, final Map<String, List<String>> lcss, final List<String> keys){
        final List<String> additionsToBeRemoved = new ArrayList<>(0);
        for(int i = 0; i < keys.size(); i ++){
            final String key = keys.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 haveIdenticalGlyphs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static boolean haveIdenticalGlyphs(final Font font, final float maxDifferenceThreshold, final char... chrs){
        final BufferedImage[] glyphs = new BufferedImage[chrs.length];
        glyphs[0] = renderImage(font, chrs[0]);
        for(int i = 0; i < chrs.length - 1; i ++)
            for(int j = i + 1; j < chrs.length; j ++){
Severity: Minor
Found in src/main/java/io/github/mtrevisan/hunlinter/gui/GlyphComparator.java - About 55 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 containsTriple has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private static boolean containsTriple(final StringBuffer sb, final String compound){
        boolean repeated = false;
        final int size = sb.length() - 1;
        if(size > 1){
            final String interCompounds = sb.substring(Math.max(size - 1, 0), size + 1)

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

    private static void manageInside(final Map<Integer, IndexDataPair<String>> indexesAndRules, final List<String> syllabes,
            final CharSequence nohyp, final int wordLength){
        final int nohypLength = nohyp.length();

        int index = 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 determineCharset has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static Charset determineCharset(final Path path, final int limitLinesRead){
        String fileCharsetName = null;
        for(final Charset cs : HUNSPELL_CHARSETS){
            try(final BufferedReader reader = Files.newBufferedReader(path, cs)){
                if(fileCharsetName == 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

Method browse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    @SuppressWarnings("UseOfProcessBuilder")
    public static boolean browse(File file) throws IOException, InterruptedException{
        if(file.isFile())
            file = file.getParentFile();

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 checkValidity has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private void checkValidity(final AffixType parentType, final AffixType type, final String parentFlag, final String flag,
            final String removal, final String line, final int index){
Severity: Major
Found in src/main/java/io/github/mtrevisan/hunlinter/parsers/vos/AffixEntry.java - About 50 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            for(int k = j + 1; k < properChildrenSize; k ++)
                                if(!SetHelper.intersection(childrenGroup.get(properChildren.get(j)), childrenGroup.get(properChildren.get(k))).isEmpty())
                                    //TODO
                                    throw new IllegalStateException("Children are not disjointed, please report this case to the developer, thank you");

      Method emitArc has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private static int emitArc(final ByteBuffer bb, final OutputStream os, final int gtl, int flags, final byte label, final int targetOffset)
        Severity
        Category
        Status
        Source
        Language