Skip to content

Show line number when suggesting std::transform or std::copy#1385

Merged
amai2012 merged 1 commit into
cppcheck-opensource:masterfrom
pfultz2:useTransformLoc
Sep 21, 2018
Merged

Show line number when suggesting std::transform or std::copy#1385
amai2012 merged 1 commit into
cppcheck-opensource:masterfrom
pfultz2:useTransformLoc

Conversation

@pfultz2
Copy link
Copy Markdown
Contributor

@pfultz2 pfultz2 commented Sep 19, 2018

This fixes a bug where the source location wasn't shown when suggesting std::transform or std::copy with container inserts.

Comment thread test/teststl.cpp
"}\n",
true);
ASSERT_EQUALS("(style) Consider using std::transform algorithm instead of a raw loop.\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (style) Consider using std::transform algorithm instead of a raw loop.\n", errout.str());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop starts in line 3 - though the trigger for the message is the content which is in line 4.
In case of nested loops the message could be ambiguous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, all the messages point inside the loops, so its consistent with the other useStlAlgorithm messages. I can update the messages in another PR. This is mainly to fix the problem with messages that have no location for them.

@amai2012 amai2012 merged commit d43cd56 into cppcheck-opensource:master Sep 21, 2018
@pfultz2 pfultz2 deleted the useTransformLoc branch May 19, 2019 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants