Skip to content

Commit

Permalink
Merge pull request #249 from GenSpectrum/202-check-linter-in-ci
Browse files Browse the repository at this point in the history
build: make linter throw errors again and fix them
  • Loading branch information
fengelniederhammer authored Jan 19, 2024
2 parents 8a2bfa8 + 6bba221 commit c1e96cc
Show file tree
Hide file tree
Showing 99 changed files with 354 additions and 437 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Run clang-format style check
uses: jidicula/clang-format-action@v4.11.0
with:
clang-format-version: '16'
clang-format-version: '17'
check-path: ${{ matrix.path['check'] }}
exclude-regex: ${{ matrix.path['exclude'] }}

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ list(REMOVE_ITEM SRC_SILO_API ${SRC_TEST})

option(BUILD_WITH_CLANG_TIDY "Build process clang-tidy" ON)
if (NOT CMAKE_BUILD_TYPE STREQUAL Release AND BUILD_WITH_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES clang-tidy-17)
find_program(CLANG_TIDY_EXE NAMES clang-tidy-18)
if (NOT CLANG_TIDY_EXE)
message(STATUS "clang-tidy-17 not found.")
message(SEND_ERROR "clang-tidy not found, aborting. You can run the build with '-D BUILD_WITH_CLANG_TIDY=OFF' to disable clang-tidy.")
else ()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
message(STATUS "run clang tidy with: ${CLANG_TIDY_EXE}")
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN apk update && apk add --no-cache py3-pip \
boost-build=1.82.0-r0 \
libtbb=2021.9.0-r0

RUN pip install conan==2.0.14
RUN pip install conan==2.0.17

WORKDIR /src
COPY conanfile.py conanprofile.docker ./
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile_linter
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ RUN apt update \
&& apt install -y \
cmake=3.22.1-1ubuntu1.22.04.1 \
python3-pip=22.0.2+dfsg-1ubuntu0.4 \
software-properties-common=0.99.22.7 \
software-properties-common=0.99.22.9 \
wget=1.21.2-2ubuntu1 \
gnupg=2.2.27-3ubuntu2.1 \
lsb-release=11.1.0ubuntu4 \
&& wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
&& add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main' \
&& apt install -y clang-tidy
&& apt install -y clang-tidy-18

RUN pip install conan==2.0.11
RUN pip install conan==2.0.17

COPY conanfile.py conanprofile.docker ./
RUN mv conanprofile.docker conanprofile
Expand Down
2 changes: 2 additions & 0 deletions include/silo/database_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <map>
#include <vector>

#include "fmt/format.h"

#include "silo/common/format_number.h"
#include "silo/common/nucleotide_symbols.h"

Expand Down
2 changes: 0 additions & 2 deletions include/silo/preprocessing/partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class Partitions {
static Partitions load(std::istream& input_file);

[[nodiscard]] const std::vector<Partition>& getPartitions() const;

[[nodiscard]] const std::vector<PartitionChunk>& getAllPartitionChunks() const;
};

} // namespace silo::preprocessing
Expand Down
6 changes: 6 additions & 0 deletions include/silo/storage/database_partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ class DatabasePartition {

DatabasePartition() = default;

void validateNucleotideSequences() const;

void validateAminoAcidSequences() const;

void validateMetadataColumns() const;

public:
storage::ColumnPartitionGroup columns;
std::map<std::string, SequenceStorePartition<Nucleotide>&> nuc_sequences;
Expand Down
3 changes: 2 additions & 1 deletion include/silo/storage/sequence_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class SequenceStorePartition {
void fillNBitmaps(const std::vector<std::string>& genomes);

public:
explicit SequenceStorePartition(const std::vector<typename SymbolType::Symbol>& reference_genome
explicit SequenceStorePartition(
const std::vector<typename SymbolType::Symbol>& reference_sequence
);

const std::vector<typename SymbolType::Symbol>& reference_sequence;
Expand Down
4 changes: 2 additions & 2 deletions include/silo/zstdfasta/zstd_compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class ZstdCompressor {
ZstdCompressor(const ZstdCompressor& other);
ZstdCompressor& operator=(const ZstdCompressor& other);

ZstdCompressor(ZstdCompressor&& other);
ZstdCompressor& operator=(ZstdCompressor&& other);
ZstdCompressor(ZstdCompressor&& other) noexcept;
ZstdCompressor& operator=(ZstdCompressor&& other) noexcept;

virtual ~ZstdCompressor();

Expand Down
4 changes: 2 additions & 2 deletions include/silo/zstdfasta/zstd_decompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class ZstdDecompressor {
ZSTD_DCtx* zstd_context;

public:
ZstdDecompressor(ZstdDecompressor&& other);
ZstdDecompressor& operator=(ZstdDecompressor&& other);
ZstdDecompressor(ZstdDecompressor&& other) noexcept;
ZstdDecompressor& operator=(ZstdDecompressor&& other) noexcept;

ZstdDecompressor(const ZstdDecompressor& other) = delete;
ZstdDecompressor& operator=(const ZstdDecompressor& other) = delete;
Expand Down
7 changes: 3 additions & 4 deletions src/silo/common/aa_symbols.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "silo/common/aa_symbols.h"

#include <cassert>
#include <cstddef>

char silo::AminoAcid::symbolToChar(silo::AminoAcid::Symbol symbol) {
switch (symbol) {
Expand Down Expand Up @@ -118,12 +117,12 @@ std::optional<silo::AminoAcid::Symbol> silo::AminoAcid::charToSymbol(char charac
}

std::optional<std::vector<silo::AminoAcid::Symbol>> silo::AminoAcid::stringToSymbolVector(
const std::string& nucleotides
const std::string& sequence
) {
const size_t size = nucleotides.size();
const size_t size = sequence.size();
std::vector<silo::AminoAcid::Symbol> result(size);
for (size_t i = 0; i < size; ++i) {
auto symbol = silo::AminoAcid::charToSymbol(nucleotides[i]);
auto symbol = silo::AminoAcid::charToSymbol(sequence[i]);
if (symbol == std::nullopt) {
return std::nullopt;
}
Expand Down
1 change: 0 additions & 1 deletion src/silo/common/bidirectional_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <string>

#include "silo/common/pango_lineage.h"
#include "silo/common/types.h"

namespace silo::common {

Expand Down
1 change: 0 additions & 1 deletion src/silo/common/data_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <algorithm>
#include <chrono>
#include <compare>
#include <utility>

namespace silo {
Expand Down
2 changes: 2 additions & 0 deletions src/silo/common/format_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
namespace silo {

struct ThousandSeparator : std::numpunct<char> {
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
[[nodiscard]] char_type do_thousands_sep() const override { return '\''; }
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
[[nodiscard]] string_type do_grouping() const override { return "\3"; }
};

Expand Down
2 changes: 0 additions & 2 deletions src/silo/common/input_stream_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
#include <string>

#include <spdlog/spdlog.h>
#include <boost/iostreams/categories.hpp>
#include <boost/iostreams/detail/error.hpp>
#include <boost/iostreams/filter/lzma.hpp>
#include <boost/iostreams/filter/zstd.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/read.hpp>

#include "silo/preprocessing/preprocessing_exception.h"

Expand Down
1 change: 0 additions & 1 deletion src/silo/common/nucleotide_symbols.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "silo/common/nucleotide_symbols.h"

#include <cassert>
#include <cstddef>

namespace silo {

Expand Down
2 changes: 0 additions & 2 deletions src/silo/common/pango_lineage.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "silo/common/pango_lineage.h"

#include <compare>

std::size_t std::hash<silo::common::UnaliasedPangoLineage>::operator()(
const silo::common::UnaliasedPangoLineage& pango_lineage
) const {
Expand Down
4 changes: 2 additions & 2 deletions src/silo/common/pango_lineage.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <gtest/gtest.h>

TEST(UnaliasedPangoLineage, isSublineageOf) {
silo::common::UnaliasedPangoLineage const under_test{"A.1.2"};
const silo::common::UnaliasedPangoLineage under_test{"A.1.2"};

EXPECT_TRUE(under_test.isSublineageOf(silo::common::UnaliasedPangoLineage{"A.1"}));
EXPECT_TRUE(under_test.isSublineageOf(silo::common::UnaliasedPangoLineage{"A"}));
Expand All @@ -18,7 +18,7 @@ TEST(UnaliasedPangoLineage, isSublineageOf) {
}

TEST(PangoLineage, getParentLineages) {
silo::common::UnaliasedPangoLineage const under_test{"A.1.23.4.513"};
const silo::common::UnaliasedPangoLineage under_test{"A.1.23.4.513"};

const std::vector<silo::common::UnaliasedPangoLineage> expected = {
silo::common::UnaliasedPangoLineage{"A"},
Expand Down
1 change: 0 additions & 1 deletion src/silo/common/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <string_view>

#include "silo/common/bidirectional_map.h"
#include "silo/common/types.h"

namespace silo::common {

Expand Down
1 change: 1 addition & 0 deletions src/silo/common/string.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ TEST(String, comparesCorrectlyIfPrefixesMatchUpTo32Positions) {
}
}

// NOLINTNEXTLINE(readability-function-cognitive-complexity)
TEST(String, fastComparesCorrectlyIfPrefixesMatchUpTo32Positions) {
BidirectionalMap<std::string> dict;
const std::string value = "1234567890abcdefghijklmnopqrstuv";
Expand Down
3 changes: 2 additions & 1 deletion src/silo/common/string_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "silo/common/string_utils.h"
#include <algorithm>

#include "silo/common/string_utils.h"

namespace silo {

std::vector<std::string> splitBy(const std::string& value, const std::string_view delimiter) {
Expand Down
48 changes: 25 additions & 23 deletions src/silo/common/string_utils.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,74 @@

#include <gtest/gtest.h>

using silo::removeSymbol;
using silo::splitBy;
using std::string;
using std::string_view;
using std::vector;

TEST(splitBy, correctSplit) {
const std::string input("ABC,DEF,ADS,");
const std::string delimiter(",");
const string input("ABC,DEF,ADS,");
const string delimiter(",");

const auto result = splitBy(input, delimiter);
EXPECT_EQ(result, std::vector<std::string>({"ABC", "DEF", "ADS", ""}));
EXPECT_EQ(result, vector<string>({"ABC", "DEF", "ADS", ""}));
}

TEST(splitBy, correctSplit2) {
const std::string input("ABC");
const std::string delimiter(",");
const string input("ABC");
const string delimiter(",");

const auto result = splitBy(input, delimiter);
EXPECT_EQ(result, std::vector<std::string>({"ABC"}));
EXPECT_EQ(result, vector<string>({"ABC"}));
}

TEST(splitBy, correctSplit3) {
const std::string input("ABC.*");
const std::string delimiter(".*");
const string input("ABC.*");
const string delimiter(".*");

const auto result = splitBy(input, delimiter);
EXPECT_EQ(result, std::vector<std::string>({"ABC", ""}));
EXPECT_EQ(result, vector<string>({"ABC", ""}));
}

TEST(splitBy, correctWithEmptyString) {
const std::string input;
const std::string_view delimiter(",");
const string input;
const string_view delimiter(",");

const auto result = splitBy(input, delimiter);
EXPECT_EQ(result, std::vector<std::string>{""});
EXPECT_EQ(result, vector<string>{""});
}

TEST(removeSymbol, removesAllOccurences) {
const std::string input(R"(ABC"DEF"ADS")");
const string input(R"(ABC"DEF"ADS")");

const auto result = silo::removeSymbol(input, '\"');
EXPECT_EQ(result, std::string("ABCDEFADS"));
EXPECT_EQ(result, string("ABCDEFADS"));
}

TEST(removeSymbol, removesAtBeginning) {
const std::string input(R"("ABC)");
const string input(R"("ABC)");

const auto result = silo::removeSymbol(input, '\"');
EXPECT_EQ(result, std::string("ABC"));
EXPECT_EQ(result, string("ABC"));
}

TEST(removeSymbol, removesAtEnd) {
const std::string input(R"(ABC")");
const string input(R"(ABC")");

const auto result = silo::removeSymbol(input, '\"');
EXPECT_EQ(result, std::string("ABC"));
EXPECT_EQ(result, string("ABC"));
}

TEST(removeSymbol, removesAtBeginningAndEnd) {
const std::string input(R"("ABC")");
const string input(R"("ABC")");

const auto result = silo::removeSymbol(input, '\"');
EXPECT_EQ(result, std::string("ABC"));
EXPECT_EQ(result, string("ABC"));
}

TEST(removeSymbol, doesNotRemoveIfNotContained) {
const std::string input("ABCDEFADS");
const string input("ABCDEFADS");

const auto result = silo::removeSymbol(input, '\"');
EXPECT_EQ(result, std::string("ABCDEFADS"));
EXPECT_EQ(result, string("ABCDEFADS"));
}
1 change: 0 additions & 1 deletion src/silo/config/config_repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <map>
#include <optional>
#include <string>
#include <vector>

#include "silo/config/config_exception.h"
#include "silo/config/database_config.h"
Expand Down
9 changes: 3 additions & 6 deletions src/silo/config/database_config.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "silo/config/database_config.h"

#include <algorithm>
#include <filesystem>
#include <iterator>
#include <stdexcept>
#include <string_view>

Expand Down Expand Up @@ -193,11 +191,10 @@ std::string DatabaseSchema::getStrictOrderByClause() const {
if (date_to_sort_by.has_value()) {
SPDLOG_INFO("preprocessing - produce order by clause with a date to sort by");
return fmt::format("ORDER BY {}, {}", date_to_sort_by.value(), primary_key);
} else {
SPDLOG_INFO("preprocessing - produce order by clause without a date to sort by");

return fmt::format("ORDER BY {}", primary_key);
}

SPDLOG_INFO("preprocessing - produce order by clause without a date to sort by");
return fmt::format("ORDER BY {}", primary_key);
}

std::optional<DatabaseMetadata> DatabaseConfig::getMetadata(const std::string& name) const {
Expand Down
2 changes: 2 additions & 0 deletions src/silo/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ std::optional<std::string> Database::getDefaultSequenceName<AminoAcid>() const {
template <>
std::vector<std::string> Database::getSequenceNames<Nucleotide>() const {
std::vector<std::string> sequence_names;
sequence_names.reserve(nuc_sequences.size());
for (const auto& [name, _] : nuc_sequences) {
sequence_names.emplace_back(name);
}
Expand All @@ -90,6 +91,7 @@ std::vector<std::string> Database::getSequenceNames<Nucleotide>() const {
template <>
std::vector<std::string> Database::getSequenceNames<AminoAcid>() const {
std::vector<std::string> sequence_names;
sequence_names.reserve(aa_sequences.size());
for (const auto& [name, _] : aa_sequences) {
sequence_names.emplace_back(name);
}
Expand Down
Loading

0 comments on commit c1e96cc

Please sign in to comment.