ddebree/game-ai

View on GitHub

Showing 13 of 20 total issues

Method search has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public List<N> search(GraphFactory<N> graphFactory, N sourceNode, N goalNode) {
        final Map<N, Double> gScore = new HashMap<>();
        final Map<N, Double> fScore = new HashMap<>();
        final Map<N, N> parentNode = new HashMap<>();

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

    @Nonnull
    public M pickAMove(S state, Set<M> bestMovesSet) {
        List<M> bestMoves = Lists.newArrayList(bestMovesSet);
        if (bestMoves.isEmpty()) {
            throw new RuntimeException("No moves to select from!");

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 search has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public List<N> search(GraphFactory<N> graphFactory, N sourceNode, N goalNode) {
        final Map<N, Double> gScore = new HashMap<>();
        final Map<N, Double> fScore = new HashMap<>();
        final Map<N, N> parentNode = new HashMap<>();

    Method run has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public void run() {
            checkNotNull(stateReader);
            checkNotNull(nextStateBuilder);
    
            S state = stateReader.get();

      Method runGameLoop has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected void runGameLoop(S state) {
              int round = 0;
              while ( ! gameOverTester.isGameOver(state)) {
                  round++;
      
      

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

            @Override
            public List<N> search(GraphFactory<N> graphFactory, N sourceNode, N targetNode) {
                Set<N> visited = new HashSet<>();
                Queue<N> queue = new LinkedList<>();
                Map<N, N> parentNodes = new HashMap<>();

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

            private List<N> searchDelegate(GraphFactory<N> graphFactory, Set<N> visited, N currentNode, N endNode) {
                for (N childNode : graphFactory.getSuccessors(currentNode)) {
                    if (childNode.equals(endNode)) {
                        return ImmutableList.of(endNode);
                    }

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

            public void run() {
                checkNotNull(stateReader);
                checkNotNull(nextStateBuilder);
        
                S state = stateReader.get();

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

            private boolean dfs(GraphFactory<N> graphFactory, N sourceVertex, N targetVertex, int depthLevel, Map<N, N> parentNodes) {
                Stack<N> stack = new Stack<>();
                stack.push(sourceVertex);
        
                Map<N, Integer> depths = new HashMap<>();

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

            private boolean dfs(GraphFactory<N> graphFactory, N sourceVertex, N targetVertex, int depthLevel, Map<N, N> parentNodes) {

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

              public S findMaximumSolution(ToDoubleFunction<S> temperatureFunction) {
                  double temperature = startTemperature;
          
                  S currentBest = initialState;
                  double currentTemperature = temperatureFunction.applyAsDouble(currentBest);

          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

          Avoid too many return statements within this method.
          Open

                  return true;
          Severity: Major
          Found in board/src/main/java/io/github/ddebree/game/ai/board/geometry/Point.java - About 30 mins to fix

            Method getBestMoves has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                @Nonnull
                @Override
                public Set<M> getBestMoves(@Nonnull final S state, @Nonnull final P playerKey) {
                    checkNotNull(state);
                    checkNotNull(playerKey);

            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