mtrevisan/HunLinter

View on GitHub

Showing 338 of 403 total issues

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

        final Function<ByteArrayList, FSAAbstract> step3 = list -> {
            resetProcessing("Creating FSA (step 3/4)");

            getWorkerData()
                .withNoHeader()
src/main/java/io/github/mtrevisan/hunlinter/workers/dictionary/PoSFSAWorker.java on lines 145..169

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

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

        final Function<ByteArrayList, FSAAbstract> step3 = list -> {
            resetProcessing("Creating FSA (step 3/4)");

            getWorkerData()
                .withNoHeader()
src/main/java/io/github/mtrevisan/hunlinter/workers/dictionary/WordlistFSAWorker.java on lines 132..156

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

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

    INPUT_CONVERSION("fsa.dict.input-conversion"){
        @Override
        public Map<String, String> fromString(final String value) throws IllegalArgumentException{
            final String[] replacements = RegexHelper.split(value, SPLITTER);
            final Map<String, String> conversionPairs = new HashMap<>(replacements.length);
src/main/java/io/github/mtrevisan/hunlinter/datastructures/fsa/builders/DictionaryAttribute.java on lines 222..240

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

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

    OUTPUT_CONVERSION("fsa.dict.output-conversion"){
        @Override
        public Map<String, String> fromString(final String value) throws IllegalArgumentException{
            final String[] replacements = RegexHelper.split(value, SPLITTER);
            final Map<String, String> conversionPairs = new HashMap<>(replacements.length);
src/main/java/io/github/mtrevisan/hunlinter/datastructures/fsa/builders/DictionaryAttribute.java on lines 196..214

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

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

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

        if(lw.getData() != null){
            final String warningMessage = ExceptionHelper.getMessage(lw);
            final IndexDataPair<?> data = lw.getData();
            final int index = data.getIndex();
            final String lineText = (index >= 0? ", line " + (index + 1): StringUtils.EMPTY);
src/main/java/io/github/mtrevisan/hunlinter/workers/core/WorkerAbstract.java on lines 145..155

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

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

    @Override
    public final void actionPerformed(final ActionEvent event){
        MenuSelectionManager.defaultManager().clearSelectedPath();

        final Frame parentFrame = GUIHelper.getParentFrame((JMenuItem)event.getSource());
src/main/java/io/github/mtrevisan/hunlinter/actions/DictionaryExtractMinimalPairsAction.java on lines 80..106

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

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

        else if(le.getData() != null){
            final String errorMessage = ExceptionHelper.getMessage(le);
            final IndexDataPair<?> data = le.getData();
            final int index = data.getIndex();
            final String lineText = (index >= 0? ", line " + (index + 1): StringUtils.EMPTY);
src/main/java/io/github/mtrevisan/hunlinter/workers/core/WorkerAbstract.java on lines 159..169

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

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

    @Override
    public final void actionPerformed(final ActionEvent event){
        MenuSelectionManager.defaultManager().clearSelectedPath();

        final Frame parentFrame = GUIHelper.getParentFrame((JMenuItem)event.getSource());
src/main/java/io/github/mtrevisan/hunlinter/actions/DictionaryExtractDuplicatesAction.java on lines 83..109

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

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

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

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

                for(int i = 0; i < syns.size(); i ++){
                    final SynonymsEntry syn = syns.get(i);
                    final List<String> definitions = syn.getSynonyms();
                    final List<String> partOfSpeeches = syn.getPartOfSpeeches();
                    for(int j = 0; j < definitions.size(); j ++){
    src/main/java/io/github/mtrevisan/hunlinter/workers/thesaurus/ThesaurusLinterFSAWorker.java on lines 85..96

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

    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

                for(int i = 0; i < syns.size(); i ++){
                    final SynonymsEntry syn = syns.get(i);
                    final List<String> definitions = syn.getSynonyms();
                    final List<String> partOfSpeeches = syn.getPartOfSpeeches();
                    for(int j = 0; j < definitions.size(); j ++){
    src/main/java/io/github/mtrevisan/hunlinter/workers/thesaurus/ThesaurusLinterWorker.java on lines 95..106

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

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

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

        private static IntIntMap rightLanguageForAllStates(final FSAAbstract fsa){
            final IntIntMap numbers = new IntIntHashMap();
            fsa.visitPostOrder(state -> {
                int thisNodeNumber = 0;
                for(int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc))
    src/main/java/io/github/mtrevisan/hunlinter/datastructures/fsa/serializers/FSASerializer.java on lines 192..204

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

    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

        private static IntIntHashMap rightLanguageForAllStates(final FSAAbstract fsa){
            final IntIntHashMap numbers = new IntIntHashMap();
            fsa.visitPostOrder(state -> {
                int thisNodeNumber = 0;
                for(int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc))
    src/main/java/io/github/mtrevisan/hunlinter/datastructures/fsa/serializers/CFSASerializer.java on lines 173..185

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

    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