Skip to content

Conversation

@ryan597
Copy link
Owner

@ryan597 ryan597 commented Dec 22, 2023

What does this PR do?

Reduce compiler warnings by implementing recs

Fixes #<issue_number>

Before submitting
  • Was this discussed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?

PR review

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

@github-actions
Copy link

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy reports: 12 concern(s)
  • src/board.cpp

    src/board.cpp:107:16: warning: [readability-implicit-bool-conversion]

    implicit conversion 'int' -> bool

        } else if (isdigit(i)) {
                   ^
                              != 0
    /home/runner/work/chessengine/chessengine/src/board.cpp:120:25: warning: 64 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
      board_position.resize(64);
                            ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:128:29: warning: 64 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        size_t current_square = 64 - rank * 8 + file - 8;
                                ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:128:41: warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        size_t current_square = 64 - rank * 8 + file - 8;
                                            ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:128:52: warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        size_t current_square = 64 - rank * 8 + file - 8;
                                                       ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:131:44: warning: 32 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
          board_position.at(current_square) += 32; // convert to lowercase
                                               ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:135:26: warning: 64 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
      for (size_t i = 0; i < 64; i++) {
                             ^
    /home/runner/work/chessengine/chessengine/src/board.cpp:137:19: warning: 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        if ((i + 1) % 8 == 0) {
                      ^

    src/board.cpp:147:15: warning: [performance-for-range-copy]

    loop variable is copied but only used as const reference; consider making it a const reference

        for (auto move : temp_moves) {
                  ^
             const  &
  • src/main.cpp

    src/main.cpp:1:11: warning: [bugprone-suspicious-include]

    suspicious #include of file with '.cpp' extension

    #include "board.cpp"
              ^
    /home/runner/work/chessengine/chessengine/src/main.cpp:1:11: note: did you mean to include 'board.hpp'?

    src/main.cpp:2:11: warning: [bugprone-suspicious-include]

    suspicious #include of file with '.cpp' extension

    #include "player.cpp"
              ^
    /home/runner/work/chessengine/chessengine/src/main.cpp:2:11: note: did you mean to include 'player.hpp'?
    /home/runner/work/chessengine/chessengine/src/main.cpp:6:27: warning: 1500.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
      Player player1{"White", 1500.0, 'w'};
                              ^
    /home/runner/work/chessengine/chessengine/src/main.cpp:7:27: warning: 1600.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
      Player player2{"Black", 1600.0, 'b'};
                              ^

    src/main.cpp:17:13: warning: [performance-for-range-copy]

    loop variable is copied but only used as const reference; consider making it a const reference

      for (auto i : moves) {
                ^
           const  &
  • src/piece.hpp

    src/piece.hpp:36:7: warning: [cppcoreguidelines-special-member-functions]

    class 'Piece' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator

    class Piece {
          ^

    src/piece.hpp:45:3: warning: [modernize-use-nodiscard]

    function 'get_type' should be marked [[nodiscard]]

      auto get_type() const -> char;
      ^
      [[nodiscard]] 

    src/piece.hpp:46:3: warning: [modernize-use-nodiscard]

    function 'get_colour' should be marked [[nodiscard]]

      auto get_colour() const -> char;
      ^
      [[nodiscard]] 

    src/piece.hpp:47:3: warning: [modernize-use-nodiscard]

    function 'get_file' should be marked [[nodiscard]]

      auto get_file() const -> size_t;
      ^
      [[nodiscard]] 

    src/piece.hpp:48:3: warning: [modernize-use-nodiscard]

    function 'get_rank' should be marked [[nodiscard]]

      auto get_rank() const -> size_t;
      ^
      [[nodiscard]] 

    src/piece.hpp:49:3: warning: [modernize-use-nodiscard]

    function 'get_square' should be marked [[nodiscard]]

      auto get_square() const -> Square;
      ^
      [[nodiscard]] 

    src/piece.hpp:53:11: warning: [modernize-use-equals-default]

    use '= default' to define a trivial destructor

      virtual ~Piece() {}
              ^        ~~
                       = default;

Have any feedback or feature suggestions? Share it here.

@github-actions
Copy link

Code Coverage Report

Coverage after merging refactor/compiler_warnings into main will be
74.00%
Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
src
   board.cpp71.11%100%61.54%72.13%164, 172, 22–24, 46–47, 49–53, 58, 62–64, 66–71, 74, 76, 78, 81–84, 86–87, 90, 92, 95
   main.cpp0%100%0%0%11, 13–19, 21–22, 4, 6–7, 9
   piece.cpp73.56%100%95.83%65.08%17–34, 6–9
   piece.hpp87.50%100%66.67%100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants