From 16caffa1c3b72df8df7282a15c819f94c25dd905 Mon Sep 17 00:00:00 2001 From: hash <10xhash@gmail.com> Date: Wed, 8 Nov 2023 23:08:25 +0530 Subject: [PATCH] feat(linelength): added detector and test for linelength>120 --- contracts/example/Test.sol | 10 ++++++++++ src/issues/NC/lineLength.ts | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/issues/NC/lineLength.ts diff --git a/contracts/example/Test.sol b/contracts/example/Test.sol index efc7dd0..54cddd9 100644 --- a/contracts/example/Test.sol +++ b/contracts/example/Test.sol @@ -49,6 +49,16 @@ contract Test { b[5]; } + function test_longLine() external { + require(msg.sender == returnHighestBidder(_tokenId) || adminsContract.retrieveFunctionAdmin(msg.sender, _selector) == true || adminsContract.retrieveGlobalAdmin(msg.sender) == true, "Not allowed"); + + // 121 length + "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567"; + + // 120 length + "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456"; + } + function test_delegatecall_inloop_1() payable external { uint256 = sum; for(uint i=0; i<10 ; i++) { diff --git a/src/issues/NC/lineLength.ts b/src/issues/NC/lineLength.ts new file mode 100644 index 0000000..4801681 --- /dev/null +++ b/src/issues/NC/lineLength.ts @@ -0,0 +1,11 @@ +import { IssueTypes, RegexIssue } from '../../types'; + +const issue: RegexIssue = { + regexOrAST: 'Regex', + type: IssueTypes.NC, + title: 'Lines are too long', + description: 'The solidity style guide recommends a maximumum line length of [120 characters](https://docs.soliditylang.org/en/v0.8.17/style-guide.html#maximum-line-length)', + regex:/\S.{119,}\S/g, +}; + +export default issue;