mtrevisan/HunLinter

View on GitHub

Showing 198 of 403 total issues

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

Method buildMaxHeap has a Cognitive Complexity of 13 (exceeds 5 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){
        int progress = 0;
        for(int heapsize = low + 1; heapsize < high; heapsize ++){
            //if child is bigger than parent

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

    public final void checkReductionCorrectness(final String flag, final List<String> reducedRules, final List<String> originalLines,
            final ProgressCallback progressCallback){
        final RuleEntry ruleToBeReduced = affixData.getData(flag);
        if(ruleToBeReduced == null)
            throw new LinterException(NON_EXISTENT_RULE, flag);

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

    @Override
    public final int parse(final ParsingContext context, final AffixData affixData) throws EOFException{
        final FlagParsingStrategy strategy = affixData.getFlagParsingStrategy();

        final int numEntries = checkValidity(context);

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

    public FSAMatchResult match(final byte[] sequence, final int start, final int length, int node){
        if(node == 0)
            return new FSAMatchResult(FSAMatchResult.NO_MATCH, start, 0);

        final int end = start + 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 computeInLinkCount has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private static IntIntMap computeInLinkCount(final FSAAbstract fsa){
        final IntIntMap inLinkCount = new IntIntHashMap();
        final IntSet visited = new IntHashSet();
        final DynamicIntArray nodes = new DynamicIntArray();
        nodes.push(fsa.getRootNode());

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

    public final boolean contains(final String[] partOfSpeeches, final String[] synonyms){
        final HashSet<String> pos = (partOfSpeeches != null? new HashSet<>(Arrays.asList(partOfSpeeches)): null);
        final Set<String> syns = new HashSet<>(Arrays.asList(synonyms));
        for(final ThesaurusEntry entry : dictionary.values())
            for(final SynonymsEntry synonymsEntry : entry.getSynonyms())

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

    private static int[] computeFirstStates(final Iterable<IntIntCursor> inLinkCount, final int maxStates, final int minInLinkCount){
        final PriorityQueue<IntIntHolder> stateInLink = new PriorityQueue<>(1, COMPARATOR);
        final IntIntHolder scratch = new IntIntHolder();
        for(final IntIntCursor c : inLinkCount)
            if(c.value > minInLinkCount){

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

    private int emitNodeArcs(final FSAAbstract fsa, final OutputStream os, final int state, final int nextState) throws IOException{
        int offset = 0;
        for(int arc = fsa.getFirstArc(state); arc != 0; arc = fsa.getNextArc(arc)){
            final boolean arcTerminal = fsa.isArcTerminal(arc);
            final int target = (arcTerminal? 0: fsa.getEndNode(arc));

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

    protected static Map<String, List<DictionaryEntry>> mergeDistributions(final Map<String, List<DictionaryEntry>> compoundRules,
            final Map<String, List<DictionaryEntry>> distribution, final Integer compoundMinimumLength, final String forbiddenWordFlag){
        final List<Map.Entry<String, List<DictionaryEntry>>> list = new ArrayList<>(compoundRules.entrySet());
        list.addAll(distribution.entrySet());

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

    public static String markDefaultStress(final String word){
        if("–".equals(word))
            return word;

        char delimiter = ' ';

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

    private void variantsCheck(final Inflection inflection){
        String derivedWord = inflection.getWord().toLowerCase(Locale.ROOT);
        for(int i = 0; i < WORD_SEPARATORS.length(); i ++)
            derivedWord = StringUtils.remove(derivedWord, WORD_SEPARATORS.charAt(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 traceback has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private Trace traceback(int lastIndexA, int lastIndexB){
        final Trace trace = new Trace();
        trace.lastIndexA = lastIndexA - 1;
        trace.lastIndexB = lastIndexB - 1;
        trace.operations = new LinkedList<>();

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

    @Override
    public final void register(final FileChangeListener listener, final String... patterns){
        Objects.requireNonNull(listener, "Listener cannot be null");

        if(watcher != 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 encode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public final byte[] encode(final byte[] source, final byte[] target){
        //FIXME
        //Search for the infix that can be encoded and remove from `source` to get a maximum-length prefix of `target`.
        //This could be done more efficiently by running a smarter longest-common-subsequence algorithm and some pruning (?).

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

    private ByteBuffer advance(){
        if(arcLimit == 0)
            return null;

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

    private List<String> convertEntriesToRules(final String flag, final AffixType type, final boolean keepLongestCommonAffix,
            final List<LineEntry> entries){
        List<LineEntry> sortedEntries = Collections.emptyList();
        if(!entries.isEmpty()){
            //restore original rules

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

    private static void removeClosestRepresentatives(final List<String> population, int limitPopulation, final int minimumDistance){
        int index = 0;
        limitPopulation = Math.min(limitPopulation, population.size());
        while(index < limitPopulation){
            final String elem = population.get(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 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

Severity
Category
Status
Source
Language