Skip to content

Commit

Permalink
Merge branch 'master' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Jan 3, 2019
2 parents 078441a + 79feec3 commit 22b5ca5
Show file tree
Hide file tree
Showing 23 changed files with 2,157 additions and 1,841 deletions.
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## [1.5.0] - 2018-12-26
### Added
- Add not-rely-on-time to rules documentation [#88](https://github.com/protofire/solhint/pull/88)
- Have --max-warnings better reflect its name [#89](https://github.com/protofire/solhint/pull/89)
- Added disable-previous-line [#91](https://github.com/protofire/solhint/pull/91)
- Snake case now allows for a (single) leading underscore [#93](https://github.com/protofire/solhint/pull/93)

### Fixed
- Fixed some comment directive tests [#92](https://github.com/protofire/solhint/pull/92)

## [1.4.1] - 2018-12-10
### Added
- Allow to specify the path to the config file [#78](https://github.com/protofire/solhint/issues/78)
- Roadmap and changelog [#81](https://github.com/protofire/solhint/issues/81)

### Changed
- Upgrade grammar [#79](https://github.com/protofire/solhint/pull/79)

## [1.4.0] - 2018-10-10
### Added
- Support prettier-solidity [#72](https://github.com/protofire/solhint/pull/72)

## [1.3.0] - 2018-09-25
### Added
- Add "Projects that use solhint" to README.md file [#64](https://github.com/protofire/solhint/issues/63)
- Add prettier and airbnb [#59](https://github.com/protofire/solhint/issues/59)
- Add new feature --ignore-path option [#58](https://github.com/protofire/solhint/issues/58)
- Add contribution formatter parameter validation [#54](https://github.com/protofire/solhint/pull/54)
- Add --max-warnings [int] option [#56](https://github.com/protofire/solhint/issues/56)
- Add --quiet option [#55](https://github.com/protofire/solhint/pull/55)

### Changed
- Move rules sections out from README.md [#65](https://github.com/protofire/solhint/issues/65)
- Complete docs and readme [#61](https://github.com/protofire/solhint/issues/61)

### Fixed
- Unable to satisfy indentation rules for functions with multiple return values [#49](https://github.com/protofire/solhint/issues/49)
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ Issues and feature requests
If you have any issues to report or features to request, please use the
[issue tracker](https://github.com/protofire/solhint/issues).

### Roadmap

There's a (tentative) [roadmap](ROADMAP.md) in which we've put down what we envision to be the best-next functionalities.

Since the project is constantly evolving and new features are requested/discovered as we go, this roadmap is open for discussions and we expect it to change over time.

Roadmap-wise contributions via new issues are always welcomed.

Development
-----------

Expand Down Expand Up @@ -74,6 +82,9 @@ All code changes happen through pull requests. To create one:
3. Ensure the tests are still passing. Please remember to add tests for new features.
4. Create the pull request.

### Considerations
- It is highly encouraged to follow [The seven rules of a great Git commit message](https://chris.beams.io/posts/git-commit/#seven-rules)
- Code should be self-documented. But, in case there is any code that may be hard to understand, it must include some comments to make it easier to review and maintain later on.

License
-------
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Solhint Project
[![Donate with Ethereum](https://en.cryptobadges.io/badge/micro/0xe8cdf02efd8ab0a490d7b2cb13553389c9bc932e)](https://en.cryptobadges.io/donate/0xe8cdf02efd8ab0a490d7b2cb13553389c9bc932e)

[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/solhint/Lobby)
[![Build Status](https://travis-ci.org/protofire/solhint.svg?branch=master)](https://travis-ci.org/protofire/solhint)
[![NPM version](https://badge.fury.io/js/solhint.svg)](https://npmjs.org/package/solhint)
[![Coverage Status](https://coveralls.io/repos/github/protofire/solhint/badge.svg?branch=master)](
Expand Down Expand Up @@ -49,7 +51,8 @@ Options:
-V, --version output the version number
-f, --formatter [name] report formatter name (stylish, table, tap, unix)
-w, --max-warnings [maxWarningsNumber] number of warnings to trigger nonzero
-q --quiet report errors only - default: false
-c, --config [file_name] file to use as your .solhint.json
-q, --quiet report errors only - default: false
--ignore-path [file_name] file to use as your .solhintignore
-h, --help output usage information
Expand Down Expand Up @@ -162,6 +165,11 @@ Related documentation you may find [there](https://protofire.github.io/solhint/)
- **[VS Code: Solidity Language Support by CodeChain.io](
https://marketplace.visualstudio.com/items?itemName=kodebox.solidity-language-server)**

## Table of Contents

* [Roadmap](ROADMAP.md): The core project's roadmap - what the core team is looking to work on in the near future.
* [Contributing](CONTRIBUTING.md): The core Solhint team :heart: contributions. This describes how you can contribute to the Solhint Project.

## Acknowledgements

The grammar used by solhint was created and is maintained by [Federico Bond](https://github.com/federicobond).
Expand All @@ -171,6 +179,11 @@ You can find it [here](https://github.com/solidityj/solidity-antlr4).

MIT

## Back us
Solhint is free to use and open-sourced. If you value our effort and feel like helping us to keep pushing this tool forward, you can send us a small donation. We'll highly appreciate it :)

[![Donate with Ethereum](https://en.cryptobadges.io/badge/micro/0xe8cdf02efd8ab0a490d7b2cb13553389c9bc932e)](https://en.cryptobadges.io/donate/0xe8cdf02efd8ab0a490d7b2cb13553389c9bc932e)

## Who uses solhint?

[<img src="https://avatars2.githubusercontent.com/u/28943015?s=200&v=4" width="75px" height="75px" alt="POA Network - Public EVM Sidechain" title="POA Network - Public EVM Sidechain" style="margin: 20px 20px 0 0" />](https://github.com/poanetwork) [<img src="https://avatars3.githubusercontent.com/u/24832717?s=200&v=4" width="75px" height="75px" alt="0x" title="0x" style="margin: 20px 20px 0 0" />](https://github.com/0xProject) [<img src="https://avatars1.githubusercontent.com/u/24954468?s=200&v=4" width="75px" height="75px" alt="GNOSIS" title="GNOSIS" style="margin: 20px 20px 0 0"/>](https://github.com/gnosis)
Expand Down
23 changes: 23 additions & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Roadmap

An overview of what the core Solhint team is looking to work on over the next few months.

As a caveat - this is a living doc, and will evolve as priorities grow and shift. The Solhint project will always be adapting to new use-cases and evolutions in the blockchain world - this roadmap is more of a "North Star" of what we're looking to work on than a strict timeline.

Please feel free to fill issues on this repository if you have questions, concerns, or suggestions.


## What's next?

So, what will that new chapter hold? We see a few major themes...

This is our next releases plan:

- 1.4.0 [released on Oct 10, 2018]
- Support prettier-solidity [#72]
- 2.0.0
- Switch from Blacklisting to Rulesets + Whitelisting [#73]
- Plugins support [#70]
- Support prettier-solidity as a plugin
- 2.1.0
- Separate core library from CLI app [#69]
81 changes: 81 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Contributing to Solhint
=======================

_Thanks for considering contributing to Solhint!_

The following is a set of guidelines for contributions. Feel free to suggest
improvements to this document in a pull request.

Issues and feature requests
---------------------------

If you have any issues to report or features to request, please use the
[issue tracker](https://github.com/protofire/solhint/issues).

Development
-----------

### Requirements

In order to develop Solhint, you'll need:

- [Git](https://git-scm.com/)
- [Node.js](https://nodejs.org/)

### Getting Started

Clone this repository and install npm dependencies:

$ git clone git@github.com:protofire/solhint.git
$ cd solhint
$ npm install

### Testing changes without re-installing

Since `solhint` is a CLI tool, the best way to test new changes immediately
after they are done is to globally link the module. Go to the repository and
run:

$ npm link

This will create a symbolic link to `solhint`'s directory. Any changes you make
will be available when you use `solhint` in any terminal.

### Running tests

If you make changes to the existing code, please make sure that all tests are
passing. If you contribute with a new feature, please add tests for it. To run the tests:

$ npm test

Grammar modifications
---------------------

Solhint uses [ANTLR4](http://www.antlr.org/) to generate the Solidity parser.
The grammar description is taken from
[solidity-antlr4](https://github.com/solidityj/solidity-antlr4). If there is
some language feature that Solhint doesn't support, the first step is to check
if the `Solidity.g4` fil is out of sync with the one in that repo. If that's the
case, the steps to update it are:

1. Copy the `Solidity.g4` file and replace the one in this repo
(`lib/grammar/Solidity.g4`).
2. From the root of the project, execute `scripts/build-grammar.sh`. You will
need to have the Java Runtime Environment (7 or later) installed for this to
work.

Pull Requests
-------------

All code changes happen through pull requests. To create one:

1. Fork the repo and create your branch from `master`.
2. Make the changes you want to do.
3. Ensure the tests are still passing. Please remember to add tests for new features.
4. Create the pull request.


License
-------

By contributing, you agree that your contributions will be licensed under its MIT License.
20 changes: 16 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ description: This is an open source project for validating Solidity code.
---

## Solhint Project
[![Donate with Ethereum](https://en.cryptobadges.io/badge/micro/0xe8cdf02efd8ab0a490d7b2cb13553389c9bc932e)](https://en.cryptobadges.io/donate/0xe8cdf02efd8ab0a490d7b2cb13553389c9bc932e)

[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/solhint/Lobby)
[![Build Status](https://travis-ci.org/protofire/solhint.svg?branch=master)](https://travis-ci.org/protofire/solhint)
[![npm version](http://img.shields.io/npm/v/solhint.svg?style=flat)](https://npmjs.org/package/solhint
"View this project on npm")
[![NPM version](https://badge.fury.io/js/solhint.svg)](https://npmjs.org/package/solhint)
[![Coverage Status](https://coveralls.io/repos/github/protofire/solhint/badge.svg?branch=master)](
https://coveralls.io/github/protofire/solhint?branch=master)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/protofire/solhint/master/LICENSE)
[![dependencies Status](https://david-dm.org/protofire/solhint/status.svg)](https://david-dm.org/protofire/solhint)
[![devDependencies Status](https://david-dm.org/protofire/solhint/dev-status.svg)](https://david-dm.org/protofire/solhint?type=dev)

This is an open source project for linting [solidity](http://solidity.readthedocs.io/en/develop/) code. This project
provide both **security** and **style guide** validations.
Expand Down Expand Up @@ -83,14 +87,17 @@ See EsLint docs about formatters [here](https://eslint.org/docs/user-guide/forma
- unix
- visualstudio



### Docs

- [List of Rules](./rules.html)
- [Configuration](./configuration.html)
- [Use Solhint in Your Application](./use-in-app.html)

### Table of Contents

* [Roadmap](./roadmap.html): The core project's roadmap - what the core team is looking to work on in the near future.
* [Contributing](./contributing.html): The core Solhint team :heart: contributions. This describes how you can contribute to the Solhint Project.

### IDE Integrations

- [Sublime Text 3](https://packagecontrol.io/search/solhint)
Expand All @@ -105,3 +112,8 @@ See EsLint docs about formatters [here](https://eslint.org/docs/user-guide/forma
### Licence

MIT

### Back Us
Solhint is free to use and open-sourced. If you value our effort and feel like helping us to keep pushing this tool forward, you can send us a small donation. We'll highly appreciate it :)

[![Donate with Ethereum](https://en.cryptobadges.io/badge/micro/0xe8cdf02efd8ab0a490d7b2cb13553389c9bc932e)](https://en.cryptobadges.io/donate/0xe8cdf02efd8ab0a490d7b2cb13553389c9bc932e)
23 changes: 23 additions & 0 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Roadmap

An overview of what the core Solhint team is looking to work on over the next few months.

As a caveat - this is a living doc, and will evolve as priorities grow and shift. The Solhint project will always be adapting to new use-cases and evolutions in the blockchain world - this roadmap is more of a "North Star" of what we're looking to work on than a strict timeline.

Please feel free to fill issues on this repository if you have questions, concerns, or suggestions.


## What's next?

So, what will that new chapter hold? We see a few major themes...

This is our next releases plan:

- 1.4.0 [released on Oct 10, 2018]
- Support prettier-solidity [#72]
- 2.0.0
- Switch from Blacklisting to Rulesets + Whitelisting [#73]
- Plugins support [#70]
- Support prettier-solidity as a plugin
- 2.1.0
- Separate core library from CLI app [#69]
1 change: 1 addition & 0 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ description: List of validation rules for Solhint - Solidity security, style gui
| **avoid-tx-origin** | Avoid to use tx.origin | *[default](#options)* |
| **no-inline-assembly** | Avoid to use inline assembly. It is acceptable only in rare cases | *[default](#options)* |
| **not-rely-on-block-hash** | Do not rely on "block.blockhash". Miners can influence its value. | *[default](#options)* |
| **not-rely-on-time** | Avoid to make time-based decisions in your business logic | *[default](#options)* |
| **avoid-low-level-calls** | Avoid to use low level calls. | *[default](#options)* |

\* \- All security rules implemented according [ConsenSys Guide for Smart Contracts](https://consensys.github.io/smart-contract-best-practices/recommendations/)
Expand Down
10 changes: 10 additions & 0 deletions lib/comment-directive-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ class CommentDirectiveParser {
return
}

if (text.includes('solhint-disable-previous-line')) {
const rules = this.parseRuleIds(text, 'solhint-disable-previous-line')

if (curLine > 0) {
ruleStore.disableRules(curLine - 1, rules)
}

return
}

if (text.includes('solhint-disable')) {
const rules = this.parseRuleIds(text, 'solhint-disable')

Expand Down
10 changes: 10 additions & 0 deletions lib/common/errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class FileNotExistsError extends Error {
constructor(data) {
const { message } = data
super(message)
}
}

module.exports = {
FileNotExistsError
}
2 changes: 1 addition & 1 deletion lib/common/identifier-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
},

isUpperSnakeCase(text) {
return match(text, /[A-Z0-9]+[_A-Z0-9]*/)
return match(text, /_{0,2}[A-Z0-9]+[_A-Z0-9]*/)
},

isNotUpperSnakeCase(text) {
Expand Down
32 changes: 16 additions & 16 deletions lib/grammar/Solidity.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,22 @@ LINE_COMMENT=119
'enum'=31
'['=32
']'=33
'.'=34
'mapping'=35
'=>'=36
'memory'=37
'storage'=38
'calldata'=39
'if'=40
'else'=41
'while'=42
'assembly'=43
'do'=44
'return'=45
'throw'=46
'emit'=47
'var'=48
'address'=49
'address'=34
'.'=35
'mapping'=36
'=>'=37
'memory'=38
'storage'=39
'calldata'=40
'if'=41
'else'=42
'while'=43
'assembly'=44
'do'=45
'return'=46
'throw'=47
'emit'=48
'var'=49
'bool'=50
'string'=51
'byte'=52
Expand Down
Loading

0 comments on commit 22b5ca5

Please sign in to comment.