vscode-solidity icon indicating copy to clipboard operation
vscode-solidity copied to clipboard

Solhint Recommeded rules not working // being detected

Open Jaime-Iglesias opened this issue 5 years ago • 6 comments

Linting the following code:

pragma solidity 0.6.4;

contract IFoo {
    
    uint256 internal a;
    uint256 internal _b;
    uint256 private _c;
    string constant x = "abc";

    function _foo(uint256 _param1, uint256 param2) external pure returns (uint256 something, uint256) {
        uint256 some = _param1 + param2;
        return (some, 1);
    }

    function _fooo(uint256 param1, uint256 param2) internal pure returns (uint256, uint256) {
        uint256 some = param1 + param2;
        return (some, 1);
    }
}

Test with default linting options:

test

test

  • With these rules the extension inside VSCode does not report any error.
  • With these rules manually linting the file with npx solhint ... does not report any error either.

Test with recommended linting options:

test

test

  • With these rules the extension inside VSCode does not report any error.
  • With these rules manually linting the file with npx solhint... does report errors:

test

From what I can gather from some tests I've performed, the .solhint.json is being read by the extension, for example if I change the pragma to 0.6.3 the rule compiler-version is enforced (both in default and in recommended). Also, the settings.json from the extension is being read since if I use the sha3 function the rule avoid-sha3 gets triggered (also in both cases)

Jaime-Iglesias avatar Apr 02 '20 15:04 Jaime-Iglesias

@juanfranblanco friendly ping

I wonder if it's related to - https://github.com/juanfranblanco/vscode-solidity/issues/169

Jaime-Iglesias avatar Apr 06 '20 11:04 Jaime-Iglesias

Sorry I did not see this, actually the extension defaults to the recommended options, it might be a versioning issue, the extension is using 2.3.1.

juanfranblanco avatar Apr 06 '20 12:04 juanfranblanco

@juanfranblanco I did some further testing and it does not seem to be related to the solhint version. Linting manually keeps on giving the correct warnings while the extension indicates no problems.

test

test

test

Jaime-Iglesias avatar Apr 06 '20 12:04 Jaime-Iglesias

hmm interesting it might be related, it should have picked the other warnings as it defaults to recommended. This used to work before, so it might have been a change.

juanfranblanco avatar Apr 06 '20 12:04 juanfranblanco

It appears that this plugin does not work with solhint 0.3.x?

petejkim avatar May 14 '20 01:05 petejkim

@petejkim it works now as this extension is using solhint 3.4.0 (at the time of writing), but maybe when you wrote your comment it was still using 2.x.x version.

AlissonRS avatar Jan 06 '24 05:01 AlissonRS