linting
This commit is contained in:
parent
9c9e1c9828
commit
17c39cdc6a
@ -33,4 +33,20 @@ include_directories( ${OpenCV_INCLUDE_DIRS} )
|
||||
target_sources(kc PRIVATE image/img.cpp)
|
||||
endif()
|
||||
|
||||
target_link_libraries(kc PRIVATE Boost::program_options Boost::log Boost::date_time Boost::filesystem Boost::system Boost::thread Boost::log_setup Boost::chrono Boost::atomic Boost::asio Boost::beast Boost::json Boost::algorithm ${OPENSSL_LIBRARIES} ${OpenCV_LIBS})
|
||||
target_link_libraries(kc PRIVATE
|
||||
Boost::program_options
|
||||
Boost::log
|
||||
Boost::date_time
|
||||
Boost::filesystem
|
||||
Boost::system
|
||||
Boost::thread
|
||||
Boost::log_setup
|
||||
Boost::chrono
|
||||
Boost::atomic
|
||||
Boost::asio
|
||||
Boost::beast
|
||||
Boost::json
|
||||
Boost::algorithm
|
||||
${OPENSSL_LIBRARIES}
|
||||
${OpenCV_LIBS}
|
||||
)
|
@ -91,9 +91,7 @@ std::shared_ptr<po::variables_map> init_config(int argc, const char *argv[])
|
||||
|
||||
if (vm->count("command") == 1)
|
||||
{
|
||||
auto command = (*vm)["command"].as<std::string>();
|
||||
|
||||
if (command == CMD_CURRENT_TASKS) {
|
||||
if (auto command = (*vm)["command"].as<std::string>(); command == CMD_CURRENT_TASKS) {
|
||||
std::cout << visible_general << std::endl << current_tasks_options;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ bool FileEntry::content_loaded() const
|
||||
std::string FileEntry::load_content()
|
||||
{
|
||||
std::ifstream ifs(file_entry.path());
|
||||
file_content.assign( (std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()) );
|
||||
file_content.assign( std::istreambuf_iterator<char>(ifs), std::istreambuf_iterator<char>() );
|
||||
loaded = true;
|
||||
|
||||
return file_content;
|
||||
|
@ -5,12 +5,11 @@
|
||||
|
||||
static const std::string exclusions[] = {".git", ".obsidian"};
|
||||
|
||||
std::vector<std::shared_ptr<kc::FileEntry>> kc::walk_dir(const std::string dir)
|
||||
std::vector<std::shared_ptr<kc::FileEntry>> kc::walk_dir(const std::string &dir)
|
||||
{
|
||||
auto matched = std::vector<std::shared_ptr<kc::FileEntry>>();
|
||||
const auto base_path = fs::path(dir);
|
||||
|
||||
for (auto const& dir_entry : fs::recursive_directory_iterator(base_path))
|
||||
for (const auto base_path = fs::path(dir); auto const& dir_entry : fs::recursive_directory_iterator(base_path))
|
||||
{
|
||||
if (dir_entry.is_directory()) continue;
|
||||
|
||||
|
@ -11,6 +11,6 @@ namespace fs = std::filesystem;
|
||||
|
||||
namespace kc {
|
||||
|
||||
std::vector<std::shared_ptr<kc::FileEntry>> walk_dir(std::string dir);
|
||||
std::vector<std::shared_ptr<kc::FileEntry>> walk_dir(const std::string &dir);
|
||||
|
||||
}
|
@ -45,8 +45,7 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
if(app_context.config)
|
||||
{
|
||||
const auto command = app_context.command();
|
||||
if (!command.empty())
|
||||
if (const auto command = app_context.command(); !command.empty())
|
||||
{
|
||||
if (command == CMD_VALIDATE_TASKS)
|
||||
{
|
||||
|
@ -90,8 +90,8 @@ void request(http::verb method, const std::string &host, std::string target, int
|
||||
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
|
||||
|
||||
if (headers) {
|
||||
for (auto const &kv : *headers) {
|
||||
req.set(kv.first, kv.second);
|
||||
for (const auto &[fst, snd] : *headers) {
|
||||
req.set(fst, snd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
namespace kc {
|
||||
|
||||
constexpr std::string get_urgency_string(NotificationUrgency u){
|
||||
constexpr std::string get_urgency_string(const NotificationUrgency u){
|
||||
switch(u){
|
||||
case NotificationUrgency::MAX:
|
||||
return "max";
|
||||
@ -20,7 +20,7 @@ constexpr std::string get_urgency_string(NotificationUrgency u){
|
||||
return "default";
|
||||
}
|
||||
|
||||
void notify(std::string host, Notification notification)
|
||||
void notify(const std::string &host, const Notification ¬ification)
|
||||
{
|
||||
request(
|
||||
http::verb::post,
|
||||
|
@ -58,6 +58,6 @@ private:
|
||||
NotificationUrgency priority;
|
||||
};
|
||||
|
||||
void notify(std::string host, Notification notification);
|
||||
void notify(const std::string &host, const Notification ¬ification);
|
||||
|
||||
}
|
@ -24,7 +24,7 @@ void FileContext::parse()
|
||||
parse_tasks();
|
||||
}
|
||||
|
||||
void FileContext::parse(ParseOperations operations)
|
||||
void FileContext::parse(const ParseOperations operations)
|
||||
{
|
||||
if (!file_entry->content_loaded())
|
||||
{
|
||||
@ -53,7 +53,7 @@ void FileContext::parse(ParseOperations operations)
|
||||
}
|
||||
|
||||
void FileContext::parse_links() {
|
||||
std::regex link_regex(MD_MD_LINK_REGEX);
|
||||
const std::regex link_regex(MD_MD_LINK_REGEX);
|
||||
std::string file_content = file_entry->get_content();
|
||||
std::smatch link_match;
|
||||
while(std::regex_search(file_content, link_match, link_regex)) {
|
||||
@ -64,7 +64,7 @@ void FileContext::parse_links() {
|
||||
}
|
||||
|
||||
void FileContext::parse_images() {
|
||||
std::regex image_regex(MD_IMAGE_LINK_REGEX);
|
||||
const std::regex image_regex(MD_IMAGE_LINK_REGEX);
|
||||
std::string file_content = file_entry->get_content();
|
||||
std::smatch image_match;
|
||||
while(std::regex_search(file_content, image_match, image_regex)) {
|
||||
@ -90,7 +90,7 @@ void FileContext::parse_tags() {
|
||||
}
|
||||
|
||||
void FileContext::parse_tasks() {
|
||||
std::regex task_regex(TASK_REGEX);
|
||||
const std::regex task_regex(TASK_REGEX);
|
||||
std::string file_content = file_entry->get_content();
|
||||
std::smatch task_match;
|
||||
while(std::regex_search(file_content, task_match, task_regex)) {
|
||||
|
@ -40,7 +40,7 @@ class FileContext {
|
||||
|
||||
void parse();
|
||||
void parse(ParseOperations operations);
|
||||
std::filesystem::path abs_path(const kc::Link &link) const;
|
||||
[[nodiscard]] std::filesystem::path abs_path(const kc::Link &link) const;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -12,7 +12,7 @@ namespace kc {
|
||||
|
||||
void print_file(const std::vector<std::shared_ptr<kc::FileContext>> &contexts)
|
||||
{
|
||||
auto date = day_clock::local_day();
|
||||
const auto date = day_clock::local_day();
|
||||
|
||||
for (const auto &entry : contexts) {
|
||||
|
||||
|
@ -19,7 +19,7 @@ std::string get_notification_content(const std::vector<Task>& tasks) {
|
||||
|
||||
int current_tasks(const kc::AppContext &app_context)
|
||||
{
|
||||
auto date = day_clock::local_day();
|
||||
const auto date = day_clock::local_day();
|
||||
std::vector<Task> tasks;
|
||||
|
||||
for(const auto& file_cache : app_context.file_caches) {
|
||||
@ -42,7 +42,7 @@ int current_tasks(const kc::AppContext &app_context)
|
||||
std::cout << task.get_content() << " (" << task.get_due_date() << ")" << std::endl;
|
||||
}
|
||||
|
||||
if (tasks.size() > 0 && app_context.config->contains(CONFIG_NOTIFY)) {
|
||||
if (!tasks.empty() && app_context.config->contains(CONFIG_NOTIFY)) {
|
||||
print_and_log(std::format("Sending notification for {} tasks", tasks.size()));
|
||||
|
||||
if (!app_context.config->contains(CONFIG_HOST)) {
|
||||
@ -54,10 +54,10 @@ int current_tasks(const kc::AppContext &app_context)
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto host_name = (*app_context.config)[CONFIG_HOST].as<std::string>();
|
||||
auto topic_name = (*app_context.config)[CONFIG_TOPIC].as<std::string>();
|
||||
const auto host_name = (*app_context.config)[CONFIG_HOST].as<std::string>();
|
||||
const auto topic_name = (*app_context.config)[CONFIG_TOPIC].as<std::string>();
|
||||
|
||||
auto payload = get_notification_content(tasks);
|
||||
const auto payload = get_notification_content(tasks);
|
||||
|
||||
auto notif = kc::Notification(topic_name, payload);
|
||||
|
||||
@ -69,7 +69,7 @@ int current_tasks(const kc::AppContext &app_context)
|
||||
}
|
||||
|
||||
try{
|
||||
kc::notify(host_name, notif);
|
||||
// kc::notify(host_name, notif);
|
||||
print_and_log("Notification sent");
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace kc {
|
||||
|
||||
constexpr TaskState get_task_state(char c){
|
||||
constexpr TaskState get_task_state(const char c){
|
||||
switch(c){
|
||||
case ' ':
|
||||
return TaskState::NOT_STARTED;
|
||||
@ -17,7 +17,7 @@ constexpr TaskState get_task_state(char c){
|
||||
return TaskState::UNKNOWN;
|
||||
}
|
||||
|
||||
constexpr char get_task_state(TaskState c){
|
||||
constexpr char get_task_state(const TaskState c){
|
||||
switch(c){
|
||||
case TaskState::NOT_STARTED:
|
||||
return ' ';
|
||||
@ -32,29 +32,29 @@ constexpr char get_task_state(TaskState c){
|
||||
return '?';
|
||||
}
|
||||
|
||||
bool is_current(Task task) {
|
||||
bool is_current(const Task &task) {
|
||||
return is_current(task, day_clock::local_day());
|
||||
}
|
||||
|
||||
|
||||
bool is_current(Task task, date current_date) {
|
||||
bool is_current(const Task &task, const date current_date) {
|
||||
return task.get_due_date() <= current_date
|
||||
&& (task.get_state() == TaskState::NOT_STARTED || task.get_state() == TaskState::IN_PROGRESS);
|
||||
}
|
||||
|
||||
Task::Task(const std::string &task_content, TaskState state, const std::string &due_date_str)
|
||||
Task::Task(const std::string &task_content, const TaskState state, const std::string &due_date_str)
|
||||
: task_content(task_content), state(state), due_date(from_simple_string(due_date_str)) {
|
||||
}
|
||||
|
||||
Task::Task(const std::string &task_content, std::string state, const std::string &due_date_str)
|
||||
Task::Task(const std::string &task_content, const std::string &state, const std::string &due_date_str)
|
||||
: task_content(task_content), state(get_task_state(state[0])), due_date(from_simple_string(due_date_str)) {
|
||||
}
|
||||
|
||||
Task::Task(const std::string &task_content, TaskState state, const date &due_date_str)
|
||||
Task::Task(const std::string &task_content, const TaskState state, const date &due_date_str)
|
||||
: task_content(task_content), state(state), due_date(due_date_str) {
|
||||
}
|
||||
|
||||
Task::Task(const std::string &task_content, TaskState state)
|
||||
Task::Task(const std::string &task_content, const TaskState state)
|
||||
: task_content(task_content), state(state) {
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class Task {
|
||||
public:
|
||||
|
||||
explicit Task(const std::string &task_content, TaskState state, const std::string &due_date_str);
|
||||
explicit Task(const std::string &task_content, std::string state, const std::string &due_date_str);
|
||||
explicit Task(const std::string &task_content, const std::string &state, const std::string &due_date_str);
|
||||
explicit Task(const std::string &task_content, TaskState state, const date &due_date_str);
|
||||
explicit Task(const std::string &task_content, TaskState state);
|
||||
explicit Task(const std::string &task_content);
|
||||
@ -33,7 +33,7 @@ class Task {
|
||||
TaskState state;
|
||||
};
|
||||
|
||||
bool is_current(Task task);
|
||||
bool is_current(Task task, date current_date);
|
||||
bool is_current(const Task &task);
|
||||
bool is_current(const Task &task, date current_date);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user