Skip to content

Commit

Permalink
[codacy] fix various codacy issues
Browse files Browse the repository at this point in the history
Summary (fixed):
src/epiworld-common.hpp: Consecutive return, break, continue, goto or
  throw statements are unnecessary.

src/epiworld-common.hpp: Variable 'fun' is assigned in constructor body.

src/epiworld-common.hpp: Function parameter '_default' should be passed by
  const reference.

src/epiworldpy/__init__.py: '._core.Saver' imported but unused (F401)
  • Loading branch information
IsaccBarker committed Jun 28, 2024
1 parent 6206a58 commit 838e0bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
30 changes: 14 additions & 16 deletions src/epiworld-common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ inline std::ostream& operator<<(std::ostream &stream, const Saver& data) {
return stream;
}

static std::string parse_kwarg_string(const pybind11::kwargs& kwargs, const char* key, const std::string _default) {
static std::string parse_kwarg_string(const pybind11::kwargs& kwargs, const char* key, const std::string& _default) {
PyObject* item = PyDict_GetItemString(kwargs.ptr(), key);

if (item != nullptr) {
Expand Down Expand Up @@ -156,7 +156,6 @@ static std::vector<std::string> get_files_in_dir(const std::string& directory) {

if (dir == nullptr) {
throw std::runtime_error(directory + ": " + strerror(errno));
return found;
}

while ((entry = readdir(dir)) != nullptr) {
Expand Down Expand Up @@ -215,23 +214,22 @@ inline Saver::Saver(
std::string fn,
std::string id,
bool file_output) :
fun(epiworld::make_save_run<int>(
fn,
std::find(what.begin(), what.end(), "total_hist") != what.end(),
std::find(what.begin(), what.end(), "virus_info") != what.end(),
std::find(what.begin(), what.end(), "virus_hist") != what.end(),
std::find(what.begin(), what.end(), "tool_info") != what.end(),
std::find(what.begin(), what.end(), "tool_hist") != what.end(),
std::find(what.begin(), what.end(), "transmission") != what.end(),
std::find(what.begin(), what.end(), "transition") != what.end(),
std::find(what.begin(), what.end(), "reproductive") != what.end(),
std::find(what.begin(), what.end(), "generation") != what.end()
)),
what(what),
fn(fn),
id(id),
file_output(file_output) {
fun = epiworld::make_save_run<int>(
fn,
std::find(what.begin(), what.end(), "total_hist") != what.end(),
std::find(what.begin(), what.end(), "virus_info") != what.end(),
std::find(what.begin(), what.end(), "virus_hist") != what.end(),
std::find(what.begin(), what.end(), "tool_info") != what.end(),
std::find(what.begin(), what.end(), "tool_hist") != what.end(),
std::find(what.begin(), what.end(), "transmission") != what.end(),
std::find(what.begin(), what.end(), "transition") != what.end(),
std::find(what.begin(), what.end(), "reproductive") != what.end(),
std::find(what.begin(), what.end(), "generation") != what.end()
);
}
file_output(file_output) {}

inline void Saver::unlink_siblings() const {
auto dir = dirname(fn);
Expand Down
2 changes: 1 addition & 1 deletion src/epiworldpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from ._core import __doc__, __version__, ModelSEIR, Saver

__all__ = ["__doc__", "__version__", "ModelSEIR"]
__all__ = ["__doc__", "__version__", "ModelSEIR", "Saver"]

0 comments on commit 838e0bc

Please sign in to comment.