@@ -18,9 +18,9 @@ uint256 constant screaming_snake_case_info = 0;
1818contract ContractWithLints {
1919 uint256 VARIABLE_MIXED_CASE_INFO;
2020
21- function incorrectShiftHigh() public {
22- uint256 localValue = 50 ;
23- uint256 result = 8 >> localValue;
21+ function incorrectShiftHigh() public pure {
22+ uint256 result = 8 ;
23+ assembly { result := shr(result, 8) }
2424 }
2525 function divideBeforeMultiplyMedium() public {
2626 (1 / 2) * 3;
@@ -666,10 +666,10 @@ forgetest!(can_override_config_lint, |prj, cmd| {
666666 cmd. arg( "lint" ) . args( [ "--only-lint" , "incorrect-shift" ] ) . assert_success( ) . stderr_eq( str ![ [
667667 r#"
668668warning[incorrect-shift]: the order of args in a shift operation is incorrect
669- [FILE]:13:26
669+ [FILE]:13:30
670670 │
671- 13 │ uint256 result = 8 >> localValue;
672- │ ━ ━━━━━━━━━━━━━━
671+ 13 │ assembly { result := shr(result, 8) }
672+ │ ━━━━━━━━━━━━━━
673673 │
674674 ╰ help: https://getfoundry.sh/forge/linting/incorrect-shift
675675
@@ -707,24 +707,12 @@ warning[divide-before-multiply]: multiplication should occur before division to
707707[COMPILING_FILES] with [SOLC_VERSION]
708708[SOLC_VERSION] [ELAPSED]
709709Compiler run successful with warnings:
710- Warning (2072): Unused local variable.
711- [FILE]:13:9:
712- |
713- 13 | uint256 result = 8 >> localValue;
714- | ^^^^^^^^^^^^^^
715-
716710Warning (6133): Statement has no effect.
717711 [FILE]:16:9:
718712 |
71971316 | (1 / 2) * 3;
720714 | ^^^^^^^^^^^
721715
722- Warning (2018): Function state mutability can be restricted to pure
723- [FILE]:11:5:
724- |
725- 11 | function incorrectShiftHigh() public {
726- | ^ (Relevant source part starts here and spans across multiple lines).
727-
728716Warning (2018): Function state mutability can be restricted to pure
729717 [FILE]:15:5:
730718 |
@@ -806,24 +794,12 @@ forgetest!(build_respects_lint_on_build_false, |prj, cmd| {
806794[COMPILING_FILES] with [SOLC_VERSION]
807795[SOLC_VERSION] [ELAPSED]
808796Compiler run successful with warnings:
809- Warning (2072): Unused local variable.
810- [FILE]:13:9:
811- |
812- 13 | uint256 result = 8 >> localValue;
813- | ^^^^^^^^^^^^^^
814-
815797Warning (6133): Statement has no effect.
816798 [FILE]:16:9:
817799 |
81880016 | (1 / 2) * 3;
819801 | ^^^^^^^^^^^
820802
821- Warning (2018): Function state mutability can be restricted to pure
822- [FILE]:11:5:
823- |
824- 11 | function incorrectShiftHigh() public {
825- | ^ (Relevant source part starts here and spans across multiple lines).
826-
827803Warning (2018): Function state mutability can be restricted to pure
828804 [FILE]:15:5:
829805 |
@@ -882,24 +858,12 @@ forgetest!(build_no_lint_flag_skips_lint, |prj, cmd| {
882858[COMPILING_FILES] with [SOLC_VERSION]
883859[SOLC_VERSION] [ELAPSED]
884860Compiler run successful with warnings:
885- Warning (2072): Unused local variable.
886- [FILE]:13:9:
887- |
888- 13 | uint256 result = 8 >> localValue;
889- | ^^^^^^^^^^^^^^
890-
891861Warning (6133): Statement has no effect.
892862 [FILE]:16:9:
893863 |
89486416 | (1 / 2) * 3;
895865 | ^^^^^^^^^^^
896866
897- Warning (2018): Function state mutability can be restricted to pure
898- [FILE]:11:5:
899- |
900- 11 | function incorrectShiftHigh() public {
901- | ^ (Relevant source part starts here and spans across multiple lines).
902-
903867Warning (2018): Function state mutability can be restricted to pure
904868 [FILE]:15:5:
905869 |
@@ -1427,22 +1391,14 @@ forgetest!(pragma_inconsistent_cross_file, |prj, cmd| {
14271391
14281392 cmd. arg( "lint" ) . args( [ "--only-lint" , "pragma-inconsistent" ] ) . assert_success( ) . stderr_eq( str ![
14291393 [ r#"
1430- note[pragma-inconsistent]: 'pragma solidity ^0.8.20;' conflicts with other version requirements in the project: 0.8.20
1394+ note[pragma-inconsistent]: 2 different Solidity pragma version requirements are used: 0.8.20, ^ 0.8.20
14311395 [FILE]:3:1
14321396 │
143313973 │ pragma solidity ^0.8.20;
14341398 │ ━━━━━━━━━━━━━━━━━━━━━━━━
14351399 │
14361400 ╰ help: https://getfoundry.sh/forge/linting/pragma-inconsistent
14371401
1438- note[pragma-inconsistent]: 'pragma solidity 0.8.20;' conflicts with other version requirements in the project: ^0.8.20
1439- [FILE]:3:1
1440- │
1441- 3 │ pragma solidity 0.8.20;
1442- │ ━━━━━━━━━━━━━━━━━━━━━━━
1443- │
1444- ╰ help: https://getfoundry.sh/forge/linting/pragma-inconsistent
1445-
14461402
14471403"# ]
14481404 ] ) ;
@@ -1538,30 +1494,14 @@ forgetest!(pragma_inconsistent_duplicates_among_conflict, |prj, cmd| {
15381494
15391495 cmd. arg( "lint" ) . args( [ "--only-lint" , "pragma-inconsistent" ] ) . assert_success( ) . stderr_eq( str ![
15401496 [ r#"
1541- note[pragma-inconsistent]: 'pragma solidity 0.8.20;' conflicts with other version requirements in the project: ^0.8.20
1497+ note[pragma-inconsistent]: 2 different Solidity pragma version requirements are used: 0.8.20, ^0.8.20
15421498 [FILE]:3:1
15431499 │
154415003 │ pragma solidity 0.8.20;
15451501 │ ━━━━━━━━━━━━━━━━━━━━━━━
15461502 │
15471503 ╰ help: https://getfoundry.sh/forge/linting/pragma-inconsistent
15481504
1549- note[pragma-inconsistent]: 'pragma solidity 0.8.20;' conflicts with other version requirements in the project: ^0.8.20
1550- [FILE]:3:1
1551- │
1552- 3 │ pragma solidity 0.8.20;
1553- │ ━━━━━━━━━━━━━━━━━━━━━━━
1554- │
1555- ╰ help: https://getfoundry.sh/forge/linting/pragma-inconsistent
1556-
1557- note[pragma-inconsistent]: 'pragma solidity ^0.8.20;' conflicts with other version requirements in the project: 0.8.20
1558- [FILE]:3:1
1559- │
1560- 3 │ pragma solidity ^0.8.20;
1561- │ ━━━━━━━━━━━━━━━━━━━━━━━━
1562- │
1563- ╰ help: https://getfoundry.sh/forge/linting/pragma-inconsistent
1564-
15651505
15661506"# ]
15671507 ] ) ;
@@ -1578,22 +1518,14 @@ forgetest!(pragma_inconsistent_files_without_pragma, |prj, cmd| {
15781518
15791519 cmd. arg( "lint" ) . args( [ "--only-lint" , "pragma-inconsistent" ] ) . assert_success( ) . stderr_eq( str ![
15801520 [ r#"
1581- note[pragma-inconsistent]: 'pragma solidity 0.8.20;' conflicts with other version requirements in the project: ^0.8.20
1521+ note[pragma-inconsistent]: 2 different Solidity pragma version requirements are used: 0.8.20, ^0.8.20
15821522 [FILE]:3:1
15831523 │
158415243 │ pragma solidity 0.8.20;
15851525 │ ━━━━━━━━━━━━━━━━━━━━━━━
15861526 │
15871527 ╰ help: https://getfoundry.sh/forge/linting/pragma-inconsistent
15881528
1589- note[pragma-inconsistent]: 'pragma solidity ^0.8.20;' conflicts with other version requirements in the project: 0.8.20
1590- [FILE]:3:1
1591- │
1592- 3 │ pragma solidity ^0.8.20;
1593- │ ━━━━━━━━━━━━━━━━━━━━━━━━
1594- │
1595- ╰ help: https://getfoundry.sh/forge/linting/pragma-inconsistent
1596-
15971529
15981530"# ]
15991531 ] ) ;
0 commit comments