Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ck printer #1895

Merged
merged 47 commits into from
Sep 15, 2023
Merged

feat: ck printer #1895

merged 47 commits into from
Sep 15, 2023

Conversation

devtooligan
Copy link
Contributor

@devtooligan devtooligan commented May 5, 2023

NOTE: This pr is based on the martin-printer branch. That pr should be merged first.

DESCRIPTION:

OPEN QUESTION:

  • Is this too much info? We could limit this to just the CK Metrics (RFC, NOC, DIT, CBO) and move the other "function attribute" metrics (i.e. number of External functions) to the Complexity dashboard. The reason all of this extra info is being reported is because it needs to be calculated to get to the CK Metrics anyways, and I feel like its very helpful -- but maybe it doesn't belong here?
INFO:Printers:
CK complexity metrics

Variables
+------------+-----------------+-----------+------------+
| Contract   | State variables | Constants | Immutables |
+------------+-----------------+-----------+------------+
| IGo        |               0 |         0 |          0 |
| BContract1 |               0 |         0 |          0 |
| BContract2 |               1 |         0 |          0 |
| CContract1 |               2 |         0 |          0 |
| TOTAL      |               3 |         0 |          0 |
+------------+-----------------+-----------+------------+

Function visibility
+------------+--------+----------+----------+---------+
| Contract   | Public | External | Internal | Private |
+------------+--------+----------+----------+---------+
| IGo        |      0 |        1 |        0 |       0 |
| BContract1 |      1 |        0 |        1 |       0 |
| BContract2 |      1 |        0 |        0 |       0 |
| CContract1 |      1 |        0 |        1 |       0 |
| TOTAL      |      3 |        1 |        2 |       0 |
+------------+--------+----------+----------+---------+

State mutability
+------------+----------+------+------+
| Contract   | Mutating | View | Pure |
+------------+----------+------+------+
| IGo        |        1 |    0 |    0 |
| BContract1 |        0 |    0 |    2 |
| BContract2 |        0 |    0 |    1 |
| CContract1 |        2 |    0 |    0 |
| TOTAL      |        3 |    0 |    3 |
+------------+----------+------+------+

External/Public functions with modifiers
+------------+-------------------+----------------------+--------------+
| Contract   | External mutating | No auth or onlyOwner | No modifiers |
+------------+-------------------+----------------------+--------------+
| IGo        |                 1 |                    1 |            1 |
| BContract1 |                 0 |                    0 |            0 |
| BContract2 |                 0 |                    0 |            0 |
| CContract1 |                 1 |                    0 |            0 |
| TOTAL      |                 2 |                    1 |            1 |
+------------+-------------------+----------------------+--------------+

External calls and CK Metrics:
Response For a Class (RFC)
Number of Children (NOC)
Depth of Inheritance Tree (DIT)
Coupling Between Object Classes (CBO)
+------------+-----------+-----+-----+-----+-----+
| Contract   | Ext calls | RFC | NOC | DIT | CBO |
+------------+-----------+-----+-----+-----+-----+
| IGo        |         0 |   1 |   0 |   0 |   1 |
| BContract1 |         0 |   1 |   0 |   0 |   0 |
| BContract2 |         0 |   1 |   0 |   0 |   1 |
| CContract1 |         2 |   3 |   0 |   0 |   2 |
+------------+-----------+-----+-----+-----+-----+

@devtooligan devtooligan changed the base branch from dev to martin-printer June 15, 2023 22:35
@devtooligan devtooligan changed the base branch from martin-printer to dev June 15, 2023 22:41
@devtooligan devtooligan marked this pull request as ready for review June 15, 2023 22:41
@@ -489,6 +489,63 @@ def encode_ir_for_compare(ir: Operation) -> str:
return ""


# pylint: disable=too-many-branches
def encode_ir_for_halstead(ir: Operation) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MMh I think we should move this outside of utils/upgradeability


WIKI = "https://github.com/trailofbits/slither/wiki/Printer-documentation#ck"

def output(self, _filename):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the return types for all the functions? (use -> None if the function returns nothing)

@montyly montyly merged commit 1db0d01 into dev Sep 15, 2023
73 checks passed
@montyly montyly deleted the ck-printer branch September 15, 2023 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants