Skip to content

Commit

Permalink
Merge 07e50ff into 264a1d8
Browse files Browse the repository at this point in the history
  • Loading branch information
davidB committed Apr 4, 2022
2 parents 264a1d8 + 07e50ff commit e681d4f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Note: Can be used with `megalinter/megalinter@beta` in your GitHub Action mega-l
- Allow to provide CI_ACTION_RUN_URL to build hlink for GitHub Comments reporter messages ([[#1341](https://github.com/megalinter/megalinter/issues/1341))
- Display plugin URL in MegaLinter output logs ([[#1340](https://github.com/megalinter/megalinter/issues/1340))
- Fix public glibc public key download
- Fix `no override and no default toolchain set` when lint rust with clippy via github-action ([#975](https://github.com/megalinter/megalinter/issues/975))

- Doc
- Add instructions to upload artifacts when using MegaLinter with Jenkins
Expand Down
3 changes: 2 additions & 1 deletion megalinter/descriptors/rust.megalinter-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ install:
- ENV PATH="/root/.cargo/bin:${PATH}"
linters:
# CLIPPY
- linter_name: clippy
- class: ClippyLinter
linter_name: clippy
linter_url: https://github.com/rust-lang/rust-clippy
linter_rules_url: https://rust-lang.github.io/rust-clippy/stable/index.html
linter_rules_configuration_url: https://github.com/rust-lang/rust-clippy#configuration
Expand Down
25 changes: 25 additions & 0 deletions megalinter/linters/ClippyLinter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
"""
Use Clippy to lint rust files
"""
import logging
import os

import megalinter


class ClippyLinter(megalinter.Linter):

# To execute before linting files
def before_lint_files(self):
# Build pre-command
if not os.path.isfile(os.path.expandvars("${HOME}/.rustup/settings.toml")):
rustup_init_command = "rustup default stable"
if self.pre_commands is None:
self.pre_commands = []
# Add to pre-commands
logging.debug("clippy before_lint_files: " + rustup_init_command)
self.pre_commands.append({
"command": rustup_init_command,
"cwd": self.workspace
})

0 comments on commit e681d4f

Please sign in to comment.