roobre/chestorganizer

View on GitHub
src/main/java/es/roobre/chestorganizer/Cache.java

Summary

Maintainability
A
35 mins
Test Coverage

Method get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    synchronized Location get(Location organizerLocation, Material material) {
        Map<Material, CacheEntry<Location>> materialMap = this.holder.get(organizerLocation);
        if (materialMap != null) {
            CacheEntry<Location> entry = materialMap.get(material);
            if (entry != null && entry.time + MAX_AGE > System.currentTimeMillis()) {
Severity: Minor
Found in src/main/java/es/roobre/chestorganizer/Cache.java - About 35 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

Line is longer than 100 characters (found 105).
Open

    synchronized Location put(Location organizerLocation, Material material, Location receiverLocation) {

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Extra separation in import group before 'java.util.HashMap'
Open

import java.util.HashMap;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 136).
Open

 * TODO: This cache is only invalidated if a returned location is no longer valid, not if it is no longer the best. This is not optimal.

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Top-level class CacheEntry has to reside in its own source file.
Open

class CacheEntry<T> {

Checks that each top-level class, interface, enumor annotation resides in a source file of its own.Official description of a 'top-level' term:7.6. Top Level Type Declarations.If file doesn't contains public class, interface, enum or annotation,top-level type is the first type in file.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'java.util.HashMap' import. Should be before 'org.bukkit.Material'.
Open

import java.util.HashMap;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'java.util.Map' import. Should be before 'org.bukkit.Material'.
Open

import java.util.Map;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 127).
Open

        Map<Material, CacheEntry<Location>> materialMap = this.holder.computeIfAbsent(organizerLocation, k -> new HashMap<>());

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

There are no issues that match your filters.

Category
Status