-
Notifications
You must be signed in to change notification settings - Fork 581
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
WIP bears/go: Add GoMetaLinterBear #1933
Conversation
bears/go/GoMetaLinterBear.py
Outdated
AUTHORS_EMAILS = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
CAN_DETECT = {'Formatting','Syntax','Missing import', | ||
'Unused Code', 'Smell', 'Unreachable Code','Security'} |
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.
E231 missing whitespace after ',''
PycodestyleBear (E231), severity NORMAL, section autopep8
.
bears/go/GoMetaLinterBear.py
Outdated
AUTHORS = {'The coala developers'} | ||
AUTHORS_EMAILS = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
CAN_DETECT = {'Formatting','Syntax','Missing import', |
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.
E231 missing whitespace after ',''
PycodestyleBear (E231), severity NORMAL, section autopep8
.
bears/go/GoMetaLinterBear.py
Outdated
AUTHORS = {'The coala developers'} | ||
AUTHORS_EMAILS = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
CAN_DETECT = {'Formatting','Syntax','Missing import', |
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.
E231 missing whitespace after ',''
PycodestyleBear (E231), severity NORMAL, section autopep8
.
bears/go/GoMetaLinterBear.py
Outdated
AUTHORS = {'The coala developers'} | ||
AUTHORS_EMAILS = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
CAN_DETECT = {'Formatting','Syntax','Missing import', |
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 code does not comply to PEP8.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/bears/go/GoMetaLinterBear.py
+++ b/bears/go/GoMetaLinterBear.py
@@ -17,8 +17,8 @@
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
- CAN_DETECT = {'Formatting','Syntax','Missing import',
- 'Unused Code', 'Smell', 'Unreachable Code','Security'}
+ CAN_DETECT = {'Formatting', 'Syntax', 'Missing import',
+ 'Unused Code', 'Smell', 'Unreachable Code', 'Security'}
SEE_MORE = 'https://github.com/alecthomas/gometalinter'
@staticmethod
tests/go/GoMetaLinterBearTest.py
Outdated
|
||
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear, | ||
valid_files=(good_file_errcheck,bad_file_imports), | ||
invalid_files=(bad_file_errcheck,good_file_imports)) |
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.
E501 line too long (87 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
tests/go/GoMetaLinterBearTest.py
Outdated
|
||
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear, | ||
valid_files=(good_file_errcheck,bad_file_imports), | ||
invalid_files=(bad_file_errcheck,good_file_imports)) |
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.
E231 missing whitespace after ',''
PycodestyleBear (E231), severity NORMAL, section autopep8
.
tests/go/GoMetaLinterBearTest.py
Outdated
|
||
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear, | ||
valid_files=(good_file_errcheck,bad_file_imports), | ||
invalid_files=(bad_file_errcheck,good_file_imports)) |
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.
E128 continuation line under-indented for visual indent'
PycodestyleBear (E128), severity NORMAL, section autopep8
.
tests/go/GoMetaLinterBearTest.py
Outdated
|
||
|
||
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear, | ||
valid_files=(good_file_errcheck,bad_file_imports), |
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.
E501 line too long (85 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
tests/go/GoMetaLinterBearTest.py
Outdated
|
||
|
||
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear, | ||
valid_files=(good_file_errcheck,bad_file_imports), |
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.
E231 missing whitespace after ',''
PycodestyleBear (E231), severity NORMAL, section autopep8
.
tests/go/GoMetaLinterBearTest.py
Outdated
|
||
|
||
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear, | ||
valid_files=(good_file_errcheck,bad_file_imports), |
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.
E128 continuation line under-indented for visual indent'
PycodestyleBear (E128), severity NORMAL, section autopep8
.
tests/go/GoMetaLinterBearTest.py
Outdated
|
||
|
||
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear, | ||
valid_files=(good_file_errcheck,bad_file_imports), |
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 code does not comply to PEP8.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/tests/go/GoMetaLinterBearTest.py
+++ b/tests/go/GoMetaLinterBearTest.py
@@ -35,5 +35,6 @@
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
- valid_files=(good_file_errcheck,bad_file_imports),
- invalid_files=(bad_file_errcheck,good_file_imports))
+ valid_files=(
+ good_file_errcheck, bad_file_imports),
+ invalid_files=(bad_file_errcheck, good_file_imports))
tests/go/GoMetaLinterBearTest.py
Outdated
|
||
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear, | ||
valid_files=(good_file_errcheck,bad_file_imports), | ||
invalid_files=(bad_file_errcheck,good_file_imports)) |
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.
Line is longer than allowed. (87 > 79)
LineLengthBear, severity NORMAL, section linelength
.
tests/go/GoMetaLinterBearTest.py
Outdated
|
||
|
||
GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear, | ||
valid_files=(good_file_errcheck,bad_file_imports), |
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.
Line is longer than allowed. (85 > 79)
LineLengthBear, severity NORMAL, section linelength
.
bears/go/GoMetaLinterBear.py
Outdated
output_regex=r'(.*):(\d*):(\d*):(.*) \((\w*)\)') | ||
class GoMetaLinterBear: | ||
""" | ||
Checks the code using ``gometalinter``. This will run |
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.
"go
" codes right ?
bears/go/GoMetaLinterBear.py
Outdated
SEE_MORE = 'https://github.com/alecthomas/gometalinter' | ||
|
||
@staticmethod | ||
def create_arguments(filename, file, config_file, |
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 is bear seems to be configurable
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.
go vet - Reports potential errors that otherwise compile.
go tool vet --shadow - Reports variables that may have been unintentionally shadowed.
gotype - Syntactic and semantic analysis similar to the Go compiler.
deadcode - Finds unused code.
gocyclo - Computes the cyclomatic complexity of functions.
golint - Google's (mostly stylistic) linter.
varcheck - Find unused global variables and constants.
structcheck - Find unused struct fields.
aligncheck - Warn about un-optimally aligned structures.
errcheck - Check that error return values are used.
megacheck - Run staticcheck, gosimple and unused, sharing work.
dupl - Reports potentially duplicated code.
ineffassign - Detect when assignments to existing variables are not used.
interfacer - Suggest narrower interfaces that can be used.
unconvert - Detect redundant type conversions.
goconst - Finds repeated strings that could be replaced by a constant.
gas - Inspects source code for security problems by scanning the Go AST.
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.
maybe you should make it configurable by enabling or disabling some linters ? 😅
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.
@AsnelChristian PTAL 😃
please always run |
234469e
to
92d1580
Compare
bears/go/GoMetaLinterBear.py
Outdated
@linter(executable='gometalinter.v1', | ||
use_stdout=True, | ||
output_format='regex', | ||
output_regex=r'(.*):(?P<line>\d*):(?P<column>\d*):(?P<message>.*) \((?:\w*)\)') |
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.
Line is longer than allowed. (87 > 79)
LineLengthBear, severity NORMAL, section linelength
.
bears/go/GoMetaLinterBear.py
Outdated
@linter(executable='gometalinter.v1', | ||
use_stdout=True, | ||
output_format='regex', | ||
output_regex=r'(.*):(?P<line>\d*):(?P<column>\d*):(?P<message>.*) \((?:\w*)\)') |
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.
E501 line too long (87 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
Add GometalinterBear which replaces some of existing bears like errcheck, vet etc Closes coala#972
@Vamshi99 Please fix your tests. |
""" | ||
:param gometalinter_disable: | ||
Disable a linter. | ||
:param gometalinter_enable: |
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.
Not sure if we should list the supported linters for our users to know.
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.
Seems like the user will need to install all the linters first ?
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.
@yash-nisar Yeah, we should mention about all supported linters. Should I list them in the documentation section? Also I will add command to install all the linters.
@staticmethod | ||
def create_arguments(filename, file, config_file, | ||
gometalinter_disable: str='', | ||
gometalinter_enable: 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.
Can this be a list ? (enabling more than 1 linter)
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.
Listing doesn't work here.
https://github.com/alecthomas/gometalinter#whats-the-best-way-to-use-gometalinter-in-ci
valid_files=(good_file_errcheck, | ||
bad_file_imports), | ||
invalid_files=(bad_file_errcheck, | ||
good_file_imports)) |
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.
Maybe a test with a config_file
?
@@ -0,0 +1,40 @@ | |||
from bears.go.GoMetaLinterBear import GoMetaLinterBear | |||
from coalib.testing.LocalBearTestHelper import verify_local_bear | |||
|
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.
2 lines before the code begins 😄
@@ -0,0 +1,40 @@ | |||
from bears.go.GoMetaLinterBear import GoMetaLinterBear |
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.
Imports should be like :
from coalib.testing.LocalBearTestHelper import verify_local_bear
from bears.go.GoMetaLinterBear import GoMetaLinterBear
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.
Any reason? I think many of the tests are not written in that pattern 🤔
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.
I agree, we need to correct them, see PEP8 imports for more information.
Add GometalinterBear which replaces some of existing bears
like errcheck, vet etc
Closes #972
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:
cobot 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!