Merge pull request #1192 from fvictorio/add-solhint-support

Add solhint support
This commit is contained in:
w0rp 2017-12-07 18:50:33 +00:00 gecommit door GitHub
bovenliggende 63ecc8341d 85e0bd3314
commit c6fc9cdb7b
Geen bekende sleutel gevonden voor deze handtekening in de database
GPG sleutel-ID: 4AEE18F83AFDEB23
5 gewijzigde bestanden met toevoegingen van 101 en 2 verwijderingen

Bestand weergeven

@ -145,7 +145,7 @@ formatting.
| Scala | [scalac](http://scala-lang.org), [scalastyle](http://www.scalastyle.org) |
| Slim | [slim-lint](https://github.com/sds/slim-lint) |
| SML | [smlnj](http://www.smlnj.org/) |
| Solidity | [solium](https://github.com/duaraghav8/Solium) |
| Solidity | [solhint](https://github.com/protofire/solhint), [solium](https://github.com/duaraghav8/Solium) |
| Stylus | [stylelint](https://github.com/stylelint/stylelint) |
| SQL | [sqlint](https://github.com/purcell/sqlint) |
| Swift | [swiftlint](https://github.com/realm/SwiftLint), [swiftformat](https://github.com/nicklockwood/SwiftFormat) |

Bestand weergeven

@ -0,0 +1,30 @@
" Author: Franco Victorio - https://github.com/fvictorio
" Description: Report errors in Solidity code with solhint
function! ale_linters#solidity#solhint#Handle(buffer, lines) abort
" Matches patterns like the following:
" /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars)
let l:pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:isError = l:match[3] is? 'error'
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
\ 'code': l:match[5],
\ 'type': l:isError ? 'E' : 'W',
\})
endfor
return l:output
endfunction
call ale#linter#Define('solidity', {
\ 'name': 'solhint',
\ 'executable': 'solhint',
\ 'command': 'solhint --formatter compact %t',
\ 'callback': 'ale_linters#solidity#solhint#Handle',
\})

Bestand weergeven

@ -2,6 +2,14 @@
ALE Solidity Integration *ale-solidity-options*
===============================================================================
solhint *ale-solidity-solhint*
Solhint should work out-of-the-box. You can further configure it using a
`.solihint.json` file. See https://github.com/protofire/solhint for more
information.
===============================================================================
solium *ale-solidity-solium*

Bestand weergeven

@ -193,6 +193,7 @@ CONTENTS *ale-contents*
sml...................................|ale-sml-options|
smlnj...............................|ale-sml-smlnj|
solidity..............................|ale-solidity-options|
solhint.............................|ale-solidity-solhint|
solium..............................|ale-solidity-solium|
spec..................................|ale-spec-options|
rpmlint.............................|ale-spec-rpmlint|
@ -342,7 +343,7 @@ Notes:
* Scala: `scalac`, `scalastyle`
* Slim: `slim-lint`
* SML: `smlnj`
* Solidity: `solium`
* Solidity: `solhint, solium`
* Stylus: `stylelint`
* SQL: `sqlint`
* Swift: `swiftlint`, `swiftformat`

Bestand weergeven

@ -0,0 +1,60 @@
Before:
runtime ale_linters/solidity/solhint.vim
After:
call ale#linter#Reset()
Execute(The vint handler should parse error messages correctly):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'col': 17,
\ 'text': 'Compiler version must be fixed',
\ 'code': 'compiler-fixed',
\ 'type': 'W',
\ },
\ {
\ 'lnum': 4,
\ 'col': 8,
\ 'text': 'Use double quotes for string literals',
\ 'code': 'quotes',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 5,
\ 'col': 8,
\ 'text': 'Use double quotes for string literals',
\ 'code': 'quotes',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 13,
\ 'col': 3,
\ 'text': 'Expected indentation of 4 spaces but found 2',
\ 'code': 'indent',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 14,
\ 'col': 3,
\ 'text': 'Expected indentation of 4 spaces but found 2',
\ 'code': 'indent',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 47,
\ 'col': 3,
\ 'text': 'Function order is incorrect, public function can not go after internal function.',
\ 'code': 'func-order',
\ 'type': 'E',
\ },
\ ],
\ ale_linters#solidity#solhint#Handle(bufnr(''), [
\ 'contracts/Bounty.sol: line 1, col 17, Warning - Compiler version must be fixed (compiler-fixed)',
\ 'contracts/Bounty.sol: line 4, col 8, Error - Use double quotes for string literals (quotes)',
\ 'contracts/Bounty.sol: line 5, col 8, Error - Use double quotes for string literals (quotes)',
\ 'contracts/Bounty.sol: line 13, col 3, Error - Expected indentation of 4 spaces but found 2 (indent)',
\ 'contracts/Bounty.sol: line 14, col 3, Error - Expected indentation of 4 spaces but found 2 (indent)',
\ 'contracts/Bounty.sol: line 47, col 3, Error - Function order is incorrect, public function can not go after internal function. (func-order)',
\ ])