mtrevisan/HunLinter

View on GitHub

Showing 197 of 403 total issues

Method parse has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public final void parse(final File hypFile){
        final Path hypPath = hypFile.toPath();
        Level level = Level.NON_COMPOUND;
        charset = FileHelper.determineCharset(hypPath, -1);
        LOGGER.info(ParserManager.MARKER_APPLICATION, "The charset of the Hyphenation file is {}", charset.name());

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

    private List<Inflection> applyAffixRules(final DictionaryEntry dicEntry, final List<List<String>> allAffixes,
            final boolean isCompound, final RuleEntry overriddenRule) throws NoApplicableRuleException{
        final String circumfixFlag = affixData.getCircumfixFlag();
        final String forbiddenWordFlag = affixData.getForbiddenWordFlag();

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

    @SuppressWarnings("OverlyBroadThrowsClause")
    public final void parse(final File affFile, final String configurationLanguage) throws IOException{
        clear();

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

    private List<DictionaryEntry> extractAllAffixes(final DictionaryEntry dicEntry){
        final String word = dicEntry.getWord();
        final List<String> partOfSpeech = dicEntry.getMorphologicalFieldPartOfSpeech();

        final List<DictionaryEntry> originators = 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 addData has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public final void addData(final String word, final Hyphenation hyphenation){
        if(hyphenation != null && !orthography.hasSyllabationErrors(hyphenation.getSyllabes())){
            final List<String> syllabes = hyphenation.getSyllabes();

            final int stressIndex = orthography.getStressedSyllabeIndexFromLast(syllabes);

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

    private Collection<List<Duplicate>> extractDuplicates(final BloomFilterInterface<String> duplicatesBloomFilter){
        final Map<String, List<Duplicate>> result = new HashMap<>(0);

        if(duplicatesBloomFilter.getAddedElements() > 0){
            resetProcessing("Extracting duplicates (step 2/3)");

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

    public static void unzipFile(final File zipFile, final Path destination){
        final byte[] buffer = new byte[1024];
        try(final ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile))){
            final File dest = destination.toFile();
            ZipEntry zipEntry = zis.getNextEntry();
Severity: Minor
Found in src/main/java/io/github/mtrevisan/hunlinter/services/ZipManager.java - About 2 hrs 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

Consider simplifying this complex logical expression.
Open

            if(chr == sb.charAt(i - 1) && Arrays.binarySearch(WordVEC.VOWELS_ARRAY, chr) < 0){
                final boolean starting1With = (i == 2 && ((chr = word.charAt(0)) == 'i' || chr == 'e'));
                final boolean starting2With = (i == 3 && word.charAt(0) == 'd' && ((chr = word.charAt(1)) == 'e' || chr == 'i'));
                final boolean endingWith = (i == sb.length() - 2 && ((chr = word.charAt(word.length() - 4)) == 'o' || chr == 'e')
                    && word.charAt(word.length() - 1) == 'e');

    Method stressCheck has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        private void stressCheck(final String subword, final Inflection inflection, final boolean lastSubword){
            if(!rulesLoader.containsValidStressedWords(subword)){
                final int stresses = WordVEC.countStresses(subword);
                if(!rulesLoader.isWordCanHaveMultipleStresses() && stresses > 1)
                    throw new LinterException(MULTIPLE_STRESSES, inflection.getWord());

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

        private Map<String, List<String>> extractMinimalPairs(final File outputFile){
            final Charset charset = dicParser.getCharset();
            int totalPairs = 0;
            final Map<String, List<String>> minimalPairs = new HashMap<>(0);
            try(final BufferedReader sourceBR = Files.newBufferedReader(outputFile.toPath(), dicParser.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 makeAdditionsDisjoint has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        private static List<LineEntry> makeAdditionsDisjoint(final List<LineEntry> rules){
            //transform
            //    [rem=èra,add=[ereta, ara, era, iera, ièra, areta, iereta],cond=èra,from=…]
            //    [rem=èra,add=[ereta, ara, era, areta],cond=èra,from=…]
            //into

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

        private static int[] linearize(final FSAAbstract fsa){
            int[] linearized = new int[0];
            int last = 0;
    
            final BitSet visited = new BitSet();

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

        private List<DictionaryEntry> composeCompound(final int[] indexes, final List<List<Inflection>> entry, final StringBuffer sb){
            final String forbiddenWordFlag = affixData.getForbiddenWordFlag();
            final boolean forbidDifferentCasesInCompound = affixData.isForbidDifferentCasesInCompound();
            final boolean forbidTriples = affixData.isForbidTriplesInCompound();
            final boolean simplifyTriples = affixData.isSimplifyTriplesInCompound();

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

        private static String reduceGeminates(final CharSequence word){
            final StringBuilder sb = new StringBuilder(word);
            for(int i = 1; i < sb.length(); i ++){
                char chr = sb.charAt(i);
                if(chr == sb.charAt(i - 1) && Arrays.binarySearch(WordVEC.VOWELS_ARRAY, chr) < 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 getLastUnstressedVowelIndex has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        private static int getLastUnstressedVowelIndex(final CharSequence word, int lastLetterIndex){
            for(lastLetterIndex --; lastLetterIndex >= 0; lastLetterIndex --){
                final char chr = word.charAt(lastLetterIndex);
                if(Arrays.binarySearch(VOWELS_PLAIN_ARRAY, chr) >= 0){
                    if(chr != 'i' && chr != 'u')

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

        public final List<WordData> lookup(String word){
            final byte separator = dictionary.metadata.getSeparator();
    
            if(!dictionary.metadata.getInputConversionPairs().isEmpty())
                word = applyReplacements(word, dictionary.metadata.getInputConversionPairs());

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

        private BloomFilterInterface<String> collectDuplicates(){
            final File dicFile = dicParser.getDicFile();
            final Charset charset = dicParser.getCharset();
    
            final BloomFilterInterface<String> bloomFilter = new ScalableInMemoryBloomFilter<>(charset, dictionaryBaseData);

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

        private void calculateInflections(){
            final String language = parserManager.getLanguage();
            final String text = inputTextField.getText().trim();
    
            if(text.equals(formerInputText))

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

        private int exactMatchSearch(final String key, final int position, int length, int nodeId){
            Objects.requireNonNull(key, "Key cannot be null");
    
            int result = -1;
            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

    Severity
    Category
    Status
    Source
    Language