{"id":22144721,"url":"https://github.com/mohamedsaidsallam/halstead_cyclomatic","last_synced_at":"2025-03-24T12:19:13.556Z","repository":{"id":135770979,"uuid":"498094212","full_name":"MohamedSaidSallam/halstead_cyclomatic","owner":"MohamedSaidSallam","description":"Calculates Halstead Metric and Cyclomatic Complexity for a given java file","archived":false,"fork":false,"pushed_at":"2022-05-30T21:23:26.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T17:23:43.228Z","etag":null,"topics":["args-parser","cyclomatic-complexity","halstead-metrics","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MohamedSaidSallam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-30T20:56:06.000Z","updated_at":"2024-05-10T01:45:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e226424-7369-45cb-99ce-11a1be03720d","html_url":"https://github.com/MohamedSaidSallam/halstead_cyclomatic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedSaidSallam%2Fhalstead_cyclomatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedSaidSallam%2Fhalstead_cyclomatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedSaidSallam%2Fhalstead_cyclomatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedSaidSallam%2Fhalstead_cyclomatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MohamedSaidSallam","download_url":"https://codeload.github.com/MohamedSaidSallam/halstead_cyclomatic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245267567,"owners_count":20587459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["args-parser","cyclomatic-complexity","halstead-metrics","python"],"created_at":"2024-12-01T22:30:57.547Z","updated_at":"2025-03-24T12:19:13.526Z","avatar_url":"https://github.com/MohamedSaidSallam.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Halstead Metric and Cyclomatic Complexity for java\n\ncalculates Halstead Metric and Cyclomatic Complexity for a given java file\n\n## installation\n\n```bash\npy -m venv venv\nvenv/Scripts/python -m pip install -r requirements.txt\n```\n\n## args\n\n```bash\n(venv) $ py -m halstead_cyclomatic -h\n```\n\n```text\nusage: __main__.py [-h] JAVA_FILE\n\noutputs Halstead metrics and cyclomatic complexity for a given java file\n\npositional arguments:\n  JAVA_FILE   path to the java file\n\noptions:\n  -h, --help  show this help message and exit\n```\n\n## examples\n\njava examples can be found in the [examples](examples/) folder\n\n### 3.java\n\n#### Java\n\n```java\nclass Test2 {\n    public static void main(String[] args) {\n        int[][] a = { { 00, 01 }, { 10, 11 } };\n        int i = 99;\n        try {\n            a[val()][i = 1]++;\n        } catch (Exception e) {\n            System.out.println(e + \", i=\" + i);\n        }\n    }\n    static int val() throws Exception {\n        throw new Exception(\"unimplemented\");\n    }\n}\n```\n\n#### Output\n\n```bash\n(venv) $ py -m halstead_cyclomatic examples/3.java\n```\n\n```text\n╒═══════════════════════╤═══╕\n│ Cyclomatic complexity │ 1 │\n╘═══════════════════════╧═══╛\n\n Halstead Metrics:\n\n╒══════════════════════════════╤═════════════╕\n│ Metric                       │       Value │\n╞══════════════════════════════╪═════════════╡\n│ Number of Distinct Operators │    22       │\n├──────────────────────────────┼─────────────┤\n│ Number of Distinct Operands  │    20       │\n├──────────────────────────────┼─────────────┤\n│ Number of Operators          │    67       │\n├──────────────────────────────┼─────────────┤\n│ Number of Operands           │    27       │\n├──────────────────────────────┼─────────────┤\n│ Program vocabulary           │    42       │\n├──────────────────────────────┼─────────────┤\n│ Program length               │    94       │\n├──────────────────────────────┼─────────────┤\n│ Estimated length             │   184.546   │\n├──────────────────────────────┼─────────────┤\n│ Purity ratio                 │     1.96326 │\n├──────────────────────────────┼─────────────┤\n│ Volume                       │   995.131   │\n├──────────────────────────────┼─────────────┤\n│ Difficulty                   │    14.85    │\n├──────────────────────────────┼─────────────┤\n│ Program effort               │ 14777.7     │\n├──────────────────────────────┼─────────────┤\n│ Time required to program     │   820.983   │\n├──────────────────────────────┼─────────────┤\n│ Number of delivered bugs     │     0.33171 │\n╘══════════════════════════════╧═════════════╛\n\n Operators:\n\n╒════════════╤═════════╕\n│ Operator   │   Count │\n╞════════════╪═════════╡\n│ class      │       1 │\n├────────────┼─────────┤\n│ {          │       8 │\n├────────────┼─────────┤\n│ public     │       1 │\n├────────────┼─────────┤\n│ static     │       2 │\n├────────────┼─────────┤\n│ void       │       1 │\n├────────────┼─────────┤\n│ (          │       6 │\n├────────────┼─────────┤\n│ [          │       5 │\n├────────────┼─────────┤\n│ ]          │       5 │\n├────────────┼─────────┤\n│ )          │       6 │\n├────────────┼─────────┤\n│ int        │       3 │\n├────────────┼─────────┤\n│ =          │       3 │\n├────────────┼─────────┤\n│ ,          │       3 │\n├────────────┼─────────┤\n│ }          │       8 │\n├────────────┼─────────┤\n│ ;          │       5 │\n├────────────┼─────────┤\n│ try        │       1 │\n├────────────┼─────────┤\n│ ++         │       1 │\n├────────────┼─────────┤\n│ catch      │       1 │\n├────────────┼─────────┤\n│ .          │       2 │\n├────────────┼─────────┤\n│ +          │       2 │\n├────────────┼─────────┤\n│ throws     │       1 │\n├────────────┼─────────┤\n│ throw      │       1 │\n├────────────┼─────────┤\n│ new        │       1 │\n╘════════════╧═════════╛\n\n Operands:\n\n╒═════════════════╤═════════╕\n│ Operand         │   Count │\n╞═════════════════╪═════════╡\n│ Test2           │       1 │\n├─────────────────┼─────────┤\n│ main            │       1 │\n├─────────────────┼─────────┤\n│ String          │       1 │\n├─────────────────┼─────────┤\n│ args            │       1 │\n├─────────────────┼─────────┤\n│ a               │       2 │\n├─────────────────┼─────────┤\n│ 00              │       1 │\n├─────────────────┼─────────┤\n│ 01              │       1 │\n├─────────────────┼─────────┤\n│ 10              │       1 │\n├─────────────────┼─────────┤\n│ 11              │       1 │\n├─────────────────┼─────────┤\n│ i               │       3 │\n├─────────────────┼─────────┤\n│ 99              │       1 │\n├─────────────────┼─────────┤\n│ val             │       2 │\n├─────────────────┼─────────┤\n│ 1               │       1 │\n├─────────────────┼─────────┤\n│ Exception       │       3 │\n├─────────────────┼─────────┤\n│ e               │       2 │\n├─────────────────┼─────────┤\n│ System          │       1 │\n├─────────────────┼─────────┤\n│ out             │       1 │\n├─────────────────┼─────────┤\n│ println         │       1 │\n├─────────────────┼─────────┤\n│ \", i=\"          │       1 │\n├─────────────────┼─────────┤\n│ \"unimplemented\" │       1 │\n╘═════════════════╧═════════╛\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedsaidsallam%2Fhalstead_cyclomatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohamedsaidsallam%2Fhalstead_cyclomatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedsaidsallam%2Fhalstead_cyclomatic/lists"}