Skip to content

Commit

Permalink
Fix SonarLint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Sep 22, 2023
1 parent fe05096 commit 61d4c02
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 36 deletions.
6 changes: 2 additions & 4 deletions include/fintamath/core/MultiMethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ class MultiMethod<Res(ArgsBase...)> {
}

Res operator()(const auto &...args) const {
auto it = callbacks.find(CallbackId(args.getType()...));

if (it != callbacks.end()) {
return it->second(args...);
if (auto iter = callbacks.find(CallbackId(args.getType()...)); iter != callbacks.end()) {
return iter->second(args...);
}

return {};
Expand Down
2 changes: 0 additions & 2 deletions include/fintamath/exceptions/Exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ namespace fintamath {

class Exception : public std::exception {
public:
~Exception() override = default;

const char *what() const noexcept override {
return "Something went wrong...";
}
Expand Down
16 changes: 4 additions & 12 deletions include/fintamath/exceptions/InvalidInputException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class InvalidInputException : public Exception {
public:
InvalidInputException() = default;

~InvalidInputException() override = default;

InvalidInputException(const std::string &input) {
explicit InvalidInputException(const std::string &input) {
content += ": " + input;
}

Expand All @@ -27,9 +25,7 @@ class InvalidInputException : public Exception {

class InvalidInputFunctionException : public InvalidInputException {
public:
~InvalidInputFunctionException() override = default;

InvalidInputFunctionException(const std::string &func, const std::vector<std::string> &argsVect) {
explicit InvalidInputFunctionException(const std::string &func, const std::vector<std::string> &argsVect) {
content += ": " + func + "(";

if (!argsVect.empty()) {
Expand All @@ -50,9 +46,7 @@ class InvalidInputFunctionException : public InvalidInputException {

class InvalidInputBinaryOperatorException : public InvalidInputException {
public:
~InvalidInputBinaryOperatorException() override = default;

InvalidInputBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) {
explicit InvalidInputBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) {
content += ": (" + lhs + ")" + oper + "(" + rhs + ")";
}
};
Expand All @@ -65,9 +59,7 @@ class InvalidInputUnaryOperatorException : public InvalidInputException {
};

public:
~InvalidInputUnaryOperatorException() override = default;

InvalidInputUnaryOperatorException(const std::string &oper, const std::string &rhs, Type type) {
explicit InvalidInputUnaryOperatorException(const std::string &oper, const std::string &rhs, Type type) {
switch (type) {
case Type::Prefix:
content += ": " + oper + "(" + rhs + ")";
Expand Down
14 changes: 3 additions & 11 deletions include/fintamath/exceptions/UndefinedException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class UndefinedException : public Exception {
public:
UndefinedException() = default;

~UndefinedException() override = default;

explicit UndefinedException(const std::string &input) {
content += ": " + input;
}
Expand All @@ -27,9 +25,7 @@ class UndefinedException : public Exception {

class UndefinedFunctionException : public UndefinedException {
public:
~UndefinedFunctionException() override = default;

UndefinedFunctionException(const std::string &func, const std::vector<std::string> &argsVect) {
explicit UndefinedFunctionException(const std::string &func, const std::vector<std::string> &argsVect) {
content += ": " + func + "(";

if (!argsVect.empty()) {
Expand All @@ -50,9 +46,7 @@ class UndefinedFunctionException : public UndefinedException {

class UndefinedBinaryOperatorException : public UndefinedException {
public:
~UndefinedBinaryOperatorException() override = default;

UndefinedBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) {
explicit UndefinedBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) {
content += ": (" + lhs + ")" + oper + "(" + rhs + ")";
}
};
Expand All @@ -65,9 +59,7 @@ class UndefinedUnaryOperatorException : public UndefinedException {
};

public:
~UndefinedUnaryOperatorException() override = default;

UndefinedUnaryOperatorException(const std::string &oper, const std::string &rhs, Type type) {
explicit UndefinedUnaryOperatorException(const std::string &oper, const std::string &rhs, Type type) {
switch (type) {
case Type::Prefix:
content += ": " + oper + "(" + rhs + ")";
Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/IFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class IFunctionCRTP : public IFunction {
#undef I_FUNCTION_CRTP

public:
IFunctionCRTP(bool isNonExressionEvaluatable = true) : isNonExressionEvaluatableFunc(isNonExressionEvaluatable) {
explicit IFunctionCRTP(bool isNonExressionEvaluatable = true) : isNonExressionEvaluatableFunc(isNonExressionEvaluatable) {
if constexpr (IsFunctionTypeAny<Derived>::value) {
type = Type::Any;
}
Expand Down
6 changes: 3 additions & 3 deletions include/fintamath/functions/IOperator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class IOperatorCRTP : public IOperator {
#undef I_OPERATOR_CRTP

public:
IOperatorCRTP(IOperator::Priority inPriority = IOperator::Priority::Any,
bool isAssociative = false,
bool isNonExressionEvaluatable = true)
explicit IOperatorCRTP(IOperator::Priority inPriority = IOperator::Priority::Any,
bool isAssociative = false,
bool isNonExressionEvaluatable = true)
: isNonExressionEvaluatableFunc(isNonExressionEvaluatable),
priority(inPriority),
isAssociativeOper(isAssociative) {
Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/functions/other/Factorial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Factorial : public IOperatorCRTP<INumber, Factorial, INumber> {
Factorial() : IOperatorCRTP(IOperator::Priority::PostfixUnary) {
}

Factorial(size_t inOrder) : Factorial() {
explicit Factorial(size_t inOrder) : Factorial() {
setOrder(inOrder);
}

Expand Down
2 changes: 1 addition & 1 deletion src/fintamath/expressions/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void Expression::insertMultiplications(TermsVector &terms) {
void Expression::fixOperatorTypes(TermsVector &terms) {
bool isFixed = true;

if (auto &term = terms.front();
if (const auto &term = terms.front();
is<IOperator>(term->value) &&
!isPrefixOperator(term->value)) {

Expand Down
2 changes: 1 addition & 1 deletion src/fintamath/functions/powers/Root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ std::map<Integer, Integer> Root::roots(const Integer &lhs, const Integer &rhs) {
rootIter->second *= factor;
}
else {
rootFactors.emplace(power.denominator(), factor);
rootFactors.try_emplace(power.denominator(), factor);
}
}

Expand Down

0 comments on commit 61d4c02

Please sign in to comment.