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
CPPCheckBear.py: Support language parameter #2710
base: master
Are you sure you want to change the base?
Conversation
bears/c_languages/CPPCheckBear.py
Outdated
""" | ||
args = ('--template={line}:{severity}:{id}:{message}',) | ||
files = tuple(self.file_dict.keys()) | ||
|
||
if enable: | ||
args += ('--enable=' + ','.join(enable),) | ||
|
||
if language: | ||
args += ('--language={language}',) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing because you need to add tests for these lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jayvdb , can you guide me a bit what should language parameter would do if we provide it.
Because in tests, already defined parameters are giving error or warnings.
But I am unable to understand what would it return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If existings tests are failing on your PR, it is because your code is buggy.
The existing tests for CPPCheckBear work correctly in the CI on master builds and other peoples PRs.
fa4bf9b
to
a9c5350
Compare
a9c5350
to
170ed5e
Compare
I have two different versions of cppcheck installed on two different machines. One of them has version |
@gutsytechster , you need to build a test case which works with the version of cppclean that coala uses. |
Isn't |
Yes, my apology, I should have said |
170ed5e
to
cb88880
Compare
cb88880
to
85bf532
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs rebase and tests are failing
85bf532
to
00d7c03
Compare
c2f98b9
to
cdfb5bb
Compare
2c10e0d
to
a997f62
Compare
@jayvdb can you review it? I just need to know if I am taking the correct approach for using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are getting errors in the tests. After changing the language
parameter, try to go through the logs and rectify your tests.
bears/c_languages/CPPCheckBear.py
Outdated
@@ -30,18 +33,37 @@ class CPPCheckBear: | |||
|
|||
def create_arguments(self, config_file, | |||
enable: typed_list(str) = [], | |||
language: str = '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use this:
language: str = '', | |
language: Language = Language['Unknown'], |
It will set a default of None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rajdeepbharati for your review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The part where I am confused is that the whichever parameter the user will input would be treated as a string so how come the value of variable language
will be of Language
type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if I input --language=c++
, it will be treated as "c++"
.
But what I need to do is that it should be like Language['c++']
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @gutsytechster do you still plan to work on this ? We need it for our game (play0ad.com)
You can't do what you want in one line. This won't work :
def create_arguments(self, config_file, enable: typed_list(str) = [], language: str = Language[language]):
From what I understand the default should be language = None
def create_arguments(self, config_file, enable: typed_list(str) = [], language: str = None):
Then line 55 check for
if language is not None:
try:
lang = Language[language]
if isinstance(lang, Language.CPP):
args += ('--language=c++',)
elif isinstance(lang, Language.C):
args += ('--language=c',)
else:
logging.error('Language can be either c or c++')
return
except(AttributeError):
logging.error('Language can be either c or c++')
return
else
args += ('--language=c',)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StanleySweet, thanks for update on this.
Yes, I'll finish the issue :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I think you need to add tests now. The Appveyor fails because the coberage went from 100% to 87 something
Not sure why travis fails but I guess it's related
Do younow how to write the tests ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah! I am trying to resolve these issues
63ce567
to
fdfe0d1
Compare
self.section.append(Setting('enable', 'unusedFunction')) | ||
self.section.append(Setting('language', 'c++')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing self.section.language = Language[<language_name>]
Please check other bears tests to get more information on this. As well suggesting you to have a look what does run_section_from_bear
does! You can find this function definition in coala repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KVGarg, do we add a Language
type parameter using self.section.language = Language[<language_name>]
instead of self.section.append(Setting('language', 'c++'))
or alongwith self.section.append(Setting('language', 'c++'))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
along with the line you’ve already added to the new tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Thanks
|
||
def test_no_enable_entered(self): | ||
def test_language_c(self): | ||
self.section.append(Setting('language', 'c')) | ||
results = self.get_results(self.test_files) | ||
messages = [result.message for result in results] | ||
self.assertEqual(len(messages), 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test were reporting a different number. Please check that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is getting passed on my local machine. I am not sure what else it is expecting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May the messages count is greater than 3, due to above reason. Just check with that first.
btw i reported this change request because https://ci.appveyor.com/project/coala/coala-bears/builds/26862272/job/81isokrqkuiupbf1#L1446 this was logging that there are 3 messages
fdfe0d1
to
c4e3c6f
Compare
Tests are still missing 100% coverage |
00fa538
to
4b4aa73
Compare
Hey @jayvdb can you help to find why |
It adds the command line argument 'language' which can be given whenever using the CPPCheckBear. It can hold two values either c or c++. Closes coala#2450
4b4aa73
to
cd36984
Compare
On researching, I found that the Travis is failing because it is using |
Appveyor is failing because it is using As far as I've understood, the cause for failing tests is because of using different Shouldn't we use the same versions for |
Any news ? |
@StanleySweet the parameter seems to work. But as I explained above, the tests are failing due to different versions of |
Yeah, I was actually just bumping the ticket since it had been 18 days. |
Hey any news on this? For a C++17 code base a cppcheck version 1.90 is needed what the coala.io does not support due to the fact this PR is not merged.... Should this PR also address the change in the CI scripts? .travis.yml |
I'm also interested. |
@jayvdb Anything we can do to get this merged? |
@abhishalya Any news? |
It adds the command line argument 'language' which can be
given whenever using the CPPCheckBear. It can hold two values
either C or C++.
Closes #2450
For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!
Checklist
them.
individually. It is not sufficient to have "fixup commits" on your PR,
our bot will still report the issues for the previous commit.) You will
likely receive a lot of bot comments and build failures if coala does not
pass on every single commit!
After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.
Please consider helping us by reviewing other peoples pull requests as well:
corobo mark wip <URL>
to get it outof the review queue.
The more you review, the more your score will grow at coala.io and we will
review your PRs faster!