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

Rust Clippy #1467

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Rust Clippy #1467

wants to merge 5 commits into from

Conversation

rubdos
Copy link

@rubdos rubdos commented Feb 27, 2017

This is mostly finished now. This integrates rust-clippy with coala, which is the de-facto standard linter for Rust.

I had to work around some stuff. CircleCI uses a rewrite for github clone urls in their default .gitconfig file. As cargo, which is the Rust package manager, doesn't like that, I had to circumvent that. When this issue, which I am tracking, closes, I'll come and remove the workaround. It consists of the git config --global --unset url.ssh://[email protected]:.insteadof option in checkout: post, and the if test in the .ci/deps.sh file. The if test is there to distinguish CircleCI from travis at that point.

On Windows, the clippy linter needs some weird directories in its PATH, because of this Rust bug.

All workarounds are annotated in the source code.

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!

TODO

return True

def run(self):
args = ('clippy', '--quiet', '--color', 'never', '--', '-Z', 'unstable-options', '--error-format', 'json', '--test')
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 (124 > 79 characters)'

PycodestyleBear (E501), severity NORMAL, section autopep8.

AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
CAN_DETECT = {'Formatting', 'Unused Code', 'Syntax', 'Unreachable Code', 'Smell', 'Code Simplification'}
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 (108 > 79 characters)'

PycodestyleBear (E501), severity NORMAL, section autopep8.

return True

def run(self):
args = ('clippy', '--quiet', '--color', 'never', '--', '-Z', 'unstable-options', '--error-format', 'json', '--test')
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/rust/RustClippyLintBear.py
+++ b/bears/rust/RustClippyLintBear.py
@@ -31,7 +31,8 @@
             return True
 
     def run(self):
-        args = ('clippy', '--quiet', '--color', 'never', '--', '-Z', 'unstable-options', '--error-format', 'json', '--test')
+        args = ('clippy', '--quiet', '--color', 'never', '--', '-Z',
+                'unstable-options', '--error-format', 'json', '--test')
         _, stderr_output = run_shell_command(
             (self.EXECUTABLE,) + args,
             cwd=self.get_config_dir(),

AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
CAN_DETECT = {'Formatting', 'Unused Code', 'Syntax', 'Unreachable Code', 'Smell', 'Code Simplification'}
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/rust/RustClippyLintBear.py
+++ b/bears/rust/RustClippyLintBear.py
@@ -13,7 +13,8 @@
     AUTHORS = {'The coala developers'}
     AUTHORS_EMAILS = {'[email protected]'}
     LICENSE = 'AGPL-3.0'
-    CAN_DETECT = {'Formatting', 'Unused Code', 'Syntax', 'Unreachable Code', 'Smell', 'Code Simplification'}
+    CAN_DETECT = {'Formatting', 'Unused Code', 'Syntax',
+                  'Unreachable Code', 'Smell', 'Code Simplification'}
     EXECUTABLE = 'cargo'
     SEVERITY_MAP = {
             # TODO: are there more?

return True

def run(self):
args = ('clippy', '--quiet', '--color', 'never', '--', '-Z', 'unstable-options', '--error-format', 'json', '--test')
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. (124 > 79)

LineLengthBear, severity NORMAL, section linelength.

@gitmate-bot
Copy link
Collaborator

Comment on 83391bd.

Shortlog of HEAD commit contains a period at end.

GitCommitBear, severity NORMAL, section commit.

AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
CAN_DETECT = {'Formatting', 'Unused Code', 'Syntax', 'Unreachable Code', 'Smell', 'Code Simplification'}
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. (108 > 79)

LineLengthBear, severity NORMAL, section linelength.

@gitmate-bot
Copy link
Collaborator

Comment on ce2c3df.

Shortlog of HEAD commit contains a period at end.

GitCommitBear, severity NORMAL, section commit.

@gitmate-bot
Copy link
Collaborator

Comment on bd35f4d.

Shortlog of HEAD commit contains a period at end.

GitCommitBear, severity NORMAL, section commit.

@gitmate-bot
Copy link
Collaborator

Comment on 588e4d2.

Shortlog of HEAD commit contains a period at end.

GitCommitBear, severity NORMAL, section commit.

@gitmate-bot
Copy link
Collaborator

Comment on 3bd43b3.

Shortlog of HEAD commit contains a period at end.

GitCommitBear, severity NORMAL, section commit.

@gitmate-bot
Copy link
Collaborator

Comment on c6e97fd.

Shortlog of HEAD commit isn't in imperative mood! Bad words are 'Debugging'

GitCommitBear, severity NORMAL, section commit.

@gitmate-bot
Copy link
Collaborator

Hey! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost!

@gitmate-bot
Copy link
Collaborator

Automated rebase was successful!

@sils
Copy link
Member

sils commented Oct 16, 2017

ack 86803af

self.assertTrue(len(results) == 1)

result = results[0]
print(result)
Copy link
Member

Choose a reason for hiding this comment

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

darn, spotted a print statement, I wanted to ack this!

@sils
Copy link
Member

sils commented Oct 16, 2017

reack 07508cf

@sils
Copy link
Member

sils commented Oct 16, 2017

unack 07508cf I meant...

@sils
Copy link
Member

sils commented Oct 16, 2017

ack 1e21230

@sils
Copy link
Member

sils commented Oct 16, 2017

From circle coala logs:

[DEBUG][15:39:49] The bear GitCommitBear raised an exception. If you are the author of this bear, please make sure to catch all exceptions. If not and this error annoys you, you might want to get in contact with the author of this bear.

Traceback information is provided below:

Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/3.5.1/lib/python3.5/site-packages/coalib/bears/Bear.py", line 308, in execute
    return [] if result is None else list(result)
  File "/home/ubuntu/.pyenv/versions/3.5.1/lib/python3.5/site-packages/bears/vcs/git/GitCommitBear.py", line 134, in run
    **self.get_issue_checks_metadata().filter_parameters(kwargs))
  File "/home/ubuntu/.pyenv/versions/3.5.1/lib/python3.5/site-packages/bears/vcs/git/GitCommitBear.py", line 302, in check_issue_reference
    body = body.splitlines()[-1]
IndexError: list index out of range

@sils
Copy link
Member

sils commented Oct 16, 2017

ack f10714f

@sils
Copy link
Member

sils commented Oct 16, 2017

ack 6ea0d82

@sils
Copy link
Member

sils commented Oct 16, 2017

@rubdos IIUC just remove the print stmt, add a body to the last commit message and file an issue about gitcommitbear should do the trick.

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.

9 participants