Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up[WIP] Tool slither-format: automatic code improvements #238
Conversation
…es on slither parsing/core and detectors. Single commit because of checking out utils/slither_format from dev-slither-format into this branch.
…ant_function passes.
…o variable types. test_unused_state_vars passes.
…ble_states passes.
…ame instead of the earlier expression name. test_solc_version passes. Removes patch_file check for now. Need to change verbose output to JSON format and include patch_file then.
…stead of the earlier expression name. test_pragma passes. Removes patch_file check for now. Need to change verbose output to JSON format and include patch_file then.
…nal_function passes.
86568a6
to
ced9498
…SON output field updates. Removed the use of event.full_name to simply use name instead (so PR #236 not required). naming-convention tests pass (except the index variable test which is expected to fail); run_all_tests passes except that one. Testing requires checking out slither core/parsing changes from dev-slither-changes-for-slither-format-new.
…_event/var_declaration, which will be removed from slither.
…ts instead of raw source text.
…constant) string.
…er --verbose option is now --verbose-test for use with unit tests.
|
Few recommendations:
|
800f375
to
2e93076
63fd179
to
99e7b81
…ical name comparison
- move to slither.formatters.x - add _format in abstract detector - simplify slither-format tool Add slither flag --generate-patches: generate patches and add them to the json Change string / bytes in create_patch functions Remove slither-format --skip-patch-generation flag
This PR (depends on #237
and #236and replaces PR #235 which was created against a staledevbranch by mistake) addresses #150 to add a new utility tool slither-format which uses slither detectors to identify code patterns of concern (w.r.t security, readability and optimisation) and automatically fix those code patterns with suggested changes.The current list of detectors used to detect and fix include:
unused-state,solc-version,pragma,naming-convention,external-function,constable-statesandconstant-function.Detectors highlight names, context and source-mapping of code constructs which are then used by slither-format to programmatically locate those constructs in the Solidity files and then replace them with changes based on best practices. Lexical analysis for identification of such constructs is confined to the smallest possible region to avoid conflicts with similarly named constructs (with potentially different types or signatures) in other scopes, functions or contracts within the same file (because of shadowing, overloading etc.).
Done: Framework and basic functionality. Unit testing.
WIP: More real-world testing and bug-fixes. More tool options.
Known bugs:
3. Bugs potentially from incorrectly reported source mappings, which might be related to #218.