Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #3

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ lint/yaml:
lint: lint/markdown lint/yaml test/styling test/static

test/static:
cppcheck --enable=all \
--inconclusive \
--library=posix \
cppcheck \
--enable=all \
--std=c++17 \
--library=posix \
--inconclusive \
--inline-suppr \
--error-exitcode=13 \
--suppress=missingIncludeSystem \
--showtime=summary \
src/

test/styling:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <iostream>
#include <vector>

#pragma once

namespace hackerrank::warmup {
int simpleArraySum(std::vector<int> ar);
int simpleArraySum(const std::vector<int>& ar);
}
20 changes: 4 additions & 16 deletions src/lib/exercises/src/hackerrank/warmup/simple_array_sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,14 @@
* @link Problem definition [[docs/hackerrank/warmup/simple_array_sum.md]]
*/

#include <iostream>
#include <cmath>
#include <numeric>
#include <vector>

using namespace std;

string ltrim(const string &);
string rtrim(const string &);
vector<string> split(const string &);


namespace hackerrank::warmup {

int simpleArraySum(std::vector<int> ar) {
int accum = 0;

for(const int i : ar) {
accum += i;
}
return accum;
int simpleArraySum(const std::vector<int>& ar) {
const int INIT_VALUE = 0;
return std::accumulate(ar.begin(), ar.end(), INIT_VALUE);
}

}
1 change: 1 addition & 0 deletions src/tests/unit/lib/foo.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <exercises/foo.hpp>

// cppcheck-suppress unusedFunction
TEST_CASE("adding numbers work", "[foo]")
{
CHECK(foo::add(0, 0) == 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#include <catch2/catch_test_macros.hpp>

#include <exercises/hackerrank/warmup/simple_array_sum.hpp>
#include <iostream>
#include <vector>

#include <filesystem>
#include <fstream>
#include <nlohmann/json.hpp>

using json = nlohmann::json;

TEST_CASE("simpleArraySum", "[warmup]")
Expand Down