fixed some clang-tidy warnings#3080
Conversation
| #include "common.h" | ||
|
|
||
| static bool executeCommand(std::string exe, std::vector<std::string> args, std::string redirect, std::string *output) | ||
| static bool executeCommand(const std::string& exe, const std::vector<std::string> &args, const std::string& redirect, std::string *output) |
There was a problem hiding this comment.
hmm.. shouldn't this use the exact same parameters as executeCommand in cppcheckexecutor.h?
There was a problem hiding this comment.
What do you mean? the signature also already was different.
There was a problem hiding this comment.
This is a callback used by CppCheck. The CppCheck constructor is:
CppCheck(ErrorLogger &errorLogger,
bool useGlobalSuppressions,
std::function<bool(std::string,std::vector<std::string>,std::string,std::string*)> executeCommand);
I believe executeCommand should match that.
There was a problem hiding this comment.
the signature also already was different.
then that should be fixed imho.
There was a problem hiding this comment.
You can update the callback signature if you want.
| Token* start = const_cast<Token*>(it->bodyStart); | ||
| Token* end = const_cast<Token*>(it->bodyEnd); | ||
| if (it->type == Scope::eGlobal) { | ||
| for (Scope &it : scopeList) { |
There was a problem hiding this comment.
I would prefer the name scope. I guess you wanted to limit the change somewhat.
| const Settings* settings) | ||
| { | ||
| std::list<ValueFlow::Value> values = {val}; | ||
| std::list<ValueFlow::Value> values = {std::move(val)}; |
There was a problem hiding this comment.
If we move the value it will always copy because its a const ref.
There was a problem hiding this comment.
The parameter is not a const ref - it's passed byvalue.
Clang or clang-tidy (can't remember) will also warn about such cases where a std::move() doesn't do anything.
There was a problem hiding this comment.
I see its val2 thats passed by const ref.
There was a problem hiding this comment.
But this is using val.
| if (idxValues.empty() || | ||
| std::any_of(idxValues.begin(), idxValues.end(), [&](const ValueFlow::Value& vidx) { | ||
| if (vidx.isImpossible()) | ||
| if (vidx.isImpossible()) |
There was a problem hiding this comment.
won't this be changed back by astyle? did you try that.
There was a problem hiding this comment.
No longer an issue with uncrustify.
5da0c84 to
a3796b5
Compare
|
Note about the unfixed |
|
@danmar This is ready for another review. |
| /** | ||
| * Execute a shell command and read the output from it. Returns true if command terminated successfully. | ||
| */ | ||
| static bool executeCommand(std::string exe, std::vector<std::string> args, const std::string &redirect, std::string *output_); |
There was a problem hiding this comment.
I think this should have the same signature as the executeCommand in gui/checkThread. It's used for the same callback. It's called from lib/cppcheck.cpp
There was a problem hiding this comment.
I have no adjusted this yet.
| if (isC()) | ||
| return; | ||
|
|
||
| const Token * templateToken = nullptr; |
There was a problem hiding this comment.
No warning from Cppcheck about this variable? Do you know if there is a ticket?
There was a problem hiding this comment.
when I look in the source code I do not see this? A rebase is needed?
https://github.com/danmar/cppcheck/blob/main/lib/tokenize.cpp#L4498
There was a problem hiding this comment.
Yes, I didn't rebase this yet. Just commented on an open conversation.
I think this might not have been detected by cppcheck and requires a ticket. I think somebody else removed it.
|
I finally addressed all remarks. So this can be reviewed again. Sorry it took so long. |
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
…ppcheck-opensource#3080 and adjusted callers to avoid unnecessary copies
No description provided.