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

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!");

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

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

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

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

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

          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);
            Severity
            Category
            Status
            Source
            Language