Skip to content

Commit

Permalink
3506: Remove cppcheck (#3509)
Browse files Browse the repository at this point in the history
cppcheck has caused our builds to fail semi-randomly multiple times. This can
happen if the CI system downloads an outdated version of cppcheck (happens on
appveyor sometimes) or if cppcheck is updated and adds new checks which cause
new false positives.

cppcheck can be useful, but it has hardly ever caught anything significant in
our code. I'd rather resort to running it locally every now and then rather
than having CI break for bogus reasons.
  • Loading branch information
kduske committed Oct 6, 2020
1 parent fd367a2 commit be5d1dc
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 134 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -13,7 +13,7 @@ matrix:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "ppa:beineri/opt-qt595-xenial"
packages:
- g++-7 qt59base qt59svg freeglut3-dev libglew-dev mesa-common-dev build-essential libglm-dev libxxf86vm-dev libfreeimage-dev pandoc cmake p7zip-full ninja-build xvfb rpm cppcheck
- g++-7 qt59base qt59svg freeglut3-dev libglew-dev mesa-common-dev build-essential libglm-dev libxxf86vm-dev libfreeimage-dev pandoc cmake p7zip-full ninja-build xvfb rpm
- os: linux
dist: xenial
env: TB_GCC8=true
Expand All @@ -23,7 +23,7 @@ matrix:
- sourceline: "ppa:ubuntu-toolchain-r/test"
- sourceline: "ppa:beineri/opt-qt595-xenial"
packages:
- g++-8 qt59base qt59svg freeglut3-dev libglew-dev mesa-common-dev build-essential libglm-dev libxxf86vm-dev libfreeimage-dev pandoc cmake p7zip-full ninja-build xvfb rpm cppcheck
- g++-8 qt59base qt59svg freeglut3-dev libglew-dev mesa-common-dev build-essential libglm-dev libxxf86vm-dev libfreeimage-dev pandoc cmake p7zip-full ninja-build xvfb rpm
- os: osx
osx_image: xcode11.3
- os: osx
Expand Down
17 changes: 1 addition & 16 deletions appveyor.bat
@@ -1,12 +1,11 @@
PATH=%PATH%;C:\Program Files (x86)\Pandoc;C:\Program Files\Cppcheck
PATH=%PATH%;C:\Program Files (x86)\Pandoc

REM Init submodules
git submodule update --init --recursive

REM Check versions
qmake -v
cmake --version
cppcheck --version

mkdir cmakebuild
cd cmakebuild
Expand All @@ -17,10 +16,6 @@ REM -DCMAKE_CXX_FLAGS=/WX

IF ERRORLEVEL 1 GOTO ERROR

cmake --build . --target cppcheck

IF ERRORLEVEL 1 GOTO ERROR_CPPCHECK

cmake --build . --config Release

IF ERRORLEVEL 1 GOTO ERROR
Expand Down Expand Up @@ -55,16 +50,6 @@ call generate_checksum.bat

GOTO END

:ERROR_CPPCHECK

echo.
echo "cppcheck detected issues, see below"
echo.

type common\cppcheck-errors.txt

echo.

:ERROR

echo "Building TrenchBroom failed"
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Expand Up @@ -14,7 +14,6 @@ environment:
PATH: '%Qt5_INSTALL_DIR%\bin;%PATH%'
install:
- cinst pandoc
- cinst cppcheck
clone_depth: 50
build_script:
- cmd: call appveyor.bat
Expand Down
2 changes: 0 additions & 2 deletions common/CMakeLists.txt
Expand Up @@ -1139,5 +1139,3 @@ add_dependencies(common generate_version)

add_subdirectory(test)
add_subdirectory(benchmark)

include(cmake/CppCheck.cmake)
85 changes: 0 additions & 85 deletions common/cmake/CppCheck.cmake

This file was deleted.

2 changes: 0 additions & 2 deletions common/src/IO/IOUtils.cpp
Expand Up @@ -35,8 +35,6 @@ namespace TrenchBroom {
namespace IO {
OpenFile::OpenFile(const Path& path, const bool write) :
file(nullptr) {
// cppcheck-suppress noCopyConstructor
// cppcheck-suppress noOperatorEq
file = fopen(path.asString().c_str(), write ? "w" : "r");
if (file == nullptr) {
throw FileSystemException("Cannot open file: " + path.asString());
Expand Down
1 change: 0 additions & 1 deletion common/src/Renderer/AllocationTracker.cpp
Expand Up @@ -154,7 +154,6 @@ namespace TrenchBroom {
// to avoid doing a redundant binary search)
Block* block = *it;
assert(block != nullptr);
// cppcheck-suppress nullPointerRedundantCheck
assert(block->free);
assert(block->prevOfSameSize == nullptr);
{
Expand Down
1 change: 0 additions & 1 deletion common/src/Renderer/AttrString.h
Expand Up @@ -54,7 +54,6 @@ namespace TrenchBroom {
public:
AttrString();

// cppcheck-suppress noExplicitConstructor
AttrString(const std::string& string);

bool operator<(const AttrString& other) const;
Expand Down
2 changes: 0 additions & 2 deletions common/src/View/MapDocument.cpp
Expand Up @@ -454,7 +454,6 @@ namespace TrenchBroom {
return setFaceAttributesExceptContentFlags(faces.back().attributes());
}

// cppcheck-suppress passedByValue
void MapDocument::loadPointFile(const IO::Path path) {
static_assert(!std::is_reference<decltype(path)>::value,
"path must be passed by value because reloadPointFile() passes m_pointFilePath");
Expand Down Expand Up @@ -496,7 +495,6 @@ namespace TrenchBroom {
pointFileWasUnloadedNotifier();
}

// cppcheck-suppress passedByValue
void MapDocument::loadPortalFile(const IO::Path path) {
static_assert(!std::is_reference<decltype(path)>::value,
"path must be passed by value because reloadPortalFile() passes m_portalFilePath");
Expand Down
2 changes: 0 additions & 2 deletions common/src/View/MapDocument.h
Expand Up @@ -261,14 +261,12 @@ namespace TrenchBroom {
bool pasteNodes(const std::vector<Model::Node*>& nodes);
bool pasteBrushFaces(const std::vector<Model::BrushFace>& faces);
public: // point file management
// cppcheck-suppress passedByValue
void loadPointFile(const IO::Path path);
bool isPointFileLoaded() const;
bool canReloadPointFile() const;
void reloadPointFile();
void unloadPointFile();
public: // portal file management
// cppcheck-suppress passedByValue
void loadPortalFile(const IO::Path path);
bool isPortalFileLoaded() const;
bool canReloadPortalFile() const;
Expand Down
1 change: 0 additions & 1 deletion common/src/View/MapFrame.cpp
Expand Up @@ -1660,7 +1660,6 @@ namespace TrenchBroom {
#endif
static void debugSegfault() {
volatile void *test = nullptr;
// cppcheck-suppress nullPointer
printf("%p\n", *((void **)test));
}
#ifdef __clang__
Expand Down
5 changes: 0 additions & 5 deletions travis-linux.sh
Expand Up @@ -18,16 +18,11 @@ export PATH=/opt/qt59/bin:${PATH}
qmake -v
cmake --version

# Ubuntu's cppcheck is too old
#cppcheck --version

# Build TB

mkdir build
cd build
cmake .. -GNinja -DCMAKE_PREFIX_PATH=/opt/qt59 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Werror" -DTB_SUPPRESS_PCH=1 || exit 1
# Ubuntu's cppcheck is too old
#cmake --build . --target cppcheck || exit 1
cmake --build . --config Release || exit 1

# Run tests (wxgtk needs an X server running for the app to initialize)
Expand Down
15 changes: 1 addition & 14 deletions travis-macos.sh
Expand Up @@ -3,15 +3,14 @@
set -o verbose

brew update > /dev/null # Discard stdout, otherwise this spams ~3000 lines to the log
brew install cmake p7zip pandoc cppcheck qt5 ninja
brew install cmake p7zip pandoc qt5 ninja

# Sometimes homebrew complains that cmake is already installed, but we need the latest version.
brew upgrade cmake

# Check versions
qmake -v
cmake --version
cppcheck --version

# Build TB

Expand All @@ -30,18 +29,6 @@ mkdir build
cd build
cmake .. -GNinja -DCMAKE_BUILD_TYPE="$BUILD_TYPE_VALUE" -DCMAKE_CXX_FLAGS="-Werror -DQT_NO_DEPRECATED_WARNINGS=1" -DTB_ENABLE_ASAN="$TB_ENABLE_ASAN_VALUE" -DTB_RUN_MACDEPLOYQT=1 -DTB_SUPPRESS_PCH=1 -DCMAKE_PREFIX_PATH="$(brew --prefix qt5)" || exit 1

cmake --build . --target cppcheck
if [[ $? -ne 0 ]] ; then
echo
echo "cppcheck detected issues, see below"
echo

cat common/cppcheck-errors.txt
echo

exit 1
fi

cmake --build . --config "$BUILD_TYPE_VALUE" || exit 1

BUILD_DIR=$(pwd)
Expand Down

0 comments on commit be5d1dc

Please sign in to comment.