Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

Vamshi99
Copy link
Member

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

  • I read the commit guidelines and I've followed
    them.
  • I ran coala over my code locally. (All commits have to pass
    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:

The more you review, the more your score will grow at coala.io and we will
review your PRs faster!

@Vamshi99 Vamshi99 changed the title bears/go: Add GoMetaLinterBear WIP bears/go: Add GoMetaLinterBear Jul 16, 2017
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
CAN_DETECT = {'Formatting','Syntax','Missing import',
'Unused Code', 'Smell', 'Unreachable Code','Security'}
Copy link
Collaborator

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.

AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
CAN_DETECT = {'Formatting','Syntax','Missing import',
Copy link
Collaborator

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.

AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
CAN_DETECT = {'Formatting','Syntax','Missing import',
Copy link
Collaborator

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.

AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
CAN_DETECT = {'Formatting','Syntax','Missing import',
Copy link
Collaborator

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


GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
valid_files=(good_file_errcheck,bad_file_imports),
invalid_files=(bad_file_errcheck,good_file_imports))
Copy link
Collaborator

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.


GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
valid_files=(good_file_errcheck,bad_file_imports),
invalid_files=(bad_file_errcheck,good_file_imports))
Copy link
Collaborator

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.


GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
valid_files=(good_file_errcheck,bad_file_imports),
invalid_files=(bad_file_errcheck,good_file_imports))
Copy link
Collaborator

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.



GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
valid_files=(good_file_errcheck,bad_file_imports),
Copy link
Collaborator

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.



GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
valid_files=(good_file_errcheck,bad_file_imports),
Copy link
Collaborator

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.



GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
valid_files=(good_file_errcheck,bad_file_imports),
Copy link
Collaborator

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.



GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
valid_files=(good_file_errcheck,bad_file_imports),
Copy link
Collaborator

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))


GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
valid_files=(good_file_errcheck,bad_file_imports),
invalid_files=(bad_file_errcheck,good_file_imports))
Copy link
Collaborator

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.



GoMetaLinterBearTest = verify_local_bear(GoMetaLinterBear,
valid_files=(good_file_errcheck,bad_file_imports),
Copy link
Collaborator

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.

output_regex=r'(.*):(\d*):(\d*):(.*) \((\w*)\)')
class GoMetaLinterBear:
"""
Checks the code using ``gometalinter``. This will run
Copy link
Member

Choose a reason for hiding this comment

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

"go" codes right ?

SEE_MORE = 'https://github.com/alecthomas/gometalinter'

@staticmethod
def create_arguments(filename, file, config_file,
Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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 ? 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

@AsnelChristian PTAL 😃

@AsnelChristian
Copy link
Member

please always run coala on the file you modified before pushing them

@Vamshi99 Vamshi99 force-pushed the metalinter branch 3 times, most recently from 234469e to 92d1580 Compare July 21, 2017 12:45
@linter(executable='gometalinter.v1',
use_stdout=True,
output_format='regex',
output_regex=r'(.*):(?P<line>\d*):(?P<column>\d*):(?P<message>.*) \((?:\w*)\)')
Copy link
Collaborator

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.

@linter(executable='gometalinter.v1',
use_stdout=True,
output_format='regex',
output_regex=r'(.*):(?P<line>\d*):(?P<column>\d*):(?P<message>.*) \((?:\w*)\)')
Copy link
Collaborator

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
@yash-nisar
Copy link
Member

@Vamshi99 Please fix your tests.

"""
:param gometalinter_disable:
Disable a linter.
:param gometalinter_enable:
Copy link
Member

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.

Copy link
Member

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 ?

Copy link
Member Author

@Vamshi99 Vamshi99 Jul 24, 2017

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='',
Copy link
Member

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

valid_files=(good_file_errcheck,
bad_file_imports),
invalid_files=(bad_file_errcheck,
good_file_imports))
Copy link
Member

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

Copy link
Member

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
Copy link
Member

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

Copy link
Member Author

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 🤔

Copy link
Member

@yash-nisar yash-nisar Jul 24, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Add bear for go-metalinter
5 participants