{"id":20801892,"url":"https://github.com/philips-software/functiondefextractor","last_synced_at":"2025-05-07T00:45:48.647Z","repository":{"id":43638418,"uuid":"249128251","full_name":"philips-software/functiondefextractor","owner":"philips-software","description":"Project intent is to solve the technical debt in the program by enabling the similarity processing and enabling the pattern searching in the code to suggest the refinement in code   ","archived":false,"fork":false,"pushed_at":"2023-03-09T07:08:17.000Z","size":777,"stargazers_count":8,"open_issues_count":3,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T04:41:14.784Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philips-software.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-22T06:43:23.000Z","updated_at":"2024-06-04T14:39:39.000Z","dependencies_parsed_at":"2022-07-13T11:20:28.038Z","dependency_job_id":null,"html_url":"https://github.com/philips-software/functiondefextractor","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Ffunctiondefextractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Ffunctiondefextractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Ffunctiondefextractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Ffunctiondefextractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philips-software","download_url":"https://codeload.github.com/philips-software/functiondefextractor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252793564,"owners_count":21805054,"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":[],"created_at":"2024-11-17T18:24:58.739Z","updated_at":"2025-05-07T00:45:48.640Z","avatar_url":"https://github.com/philips-software.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Function Extractor\n\n![Python application](https://github.com/philips-software/functiondefextractor/workflows/Python%20application/badge.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/gh/philips-software/functiondefextractor/branch/master/graph/badge.svg)](https://codecov.io/gh/philips-software/functiondefextractor)\n\nTool to extract the function definitions from the source code\n\nIt can be used to extract functions from,\n\n- C  \n\n- C++\n\n- C#  \n\n- Java  \n\n- Python\n\n- TypeScript\n\n- JavaScript\n\nAdvantage of using such function extractions are,\n\n- Resolving technical debt  \n\n- Identify function similarity  \n\n- Identify pattern check (Supresswarnings, Assert, etc...)\n  \n## Dependencies\n\n- python 3.8 : 64 bit  \n\n- python packages (xlrd, xlsxwriter, pandas)  \n\n- third party packages [Ctags, grep]\n\n## Installation\n  \n[INSTALL.md](INSTALL.md)\n\n```sh\npip install functiondefextractor\n```\n\n## Usage \u0026 Configuration\n\n### Code\n\n- General usage with out options.\n\n```sh\nfrom functiondefextractor import core_extractor\nout_put = core_extractor.extractor (r\"path_to_repo/code\")\nprint(out_put)\n```\n\n- To exclude specific files from repository.\n\n```sh\nfrom functiondefextractor import core_extractor\nout_put = core_extractor.extractor (r\"path_to_repo/code\", exclude=r'*\\test\\*,*.java')\nprint(out_put)\n```\n\nSample regex patterns:\nNote: Space given after comma(,) in regex pattern is also treated as part of\nthe pattern. For example\n\n```sh\n(*.java, *.cpp) != (*.java,*.cpp)\n```\n\n```sh\n1. '*.java' =\u003e  to exclude all java files in a repository.\n\n2. '*/test/*' =\u003e to exclude test folder and files in it.\n\n3. '*/src/*/*.cpp' =\u003e to exclude all cpp files in src and it's sub directories\n```\n\n- To extract functions based on annotation.\n\n```sh\nfrom functiondefextractor import core_extractor\nout_put = core_extractor.extractor (r\"path_to_repo/code\", annot=\"@Test\")\nprint(out_put)\n```\n\n- To extract delta lines(+/-) from code based on annotation/key word.\nNote: If user is unaware of complete annotation use this(annot with delta)\nfeature to extract functions else use the above feature. Suggested to use\ndelta=0 to get only line with annotation.\n\n```sh\nfrom functiondefextractor import core_extractor\nout_put = core_extractor.extractor(r\"path_to_repo/code\", annot=\"@SupressWarning\", delta=\"5\")\nprint(out_put)\n```\n\n- To analyse various patterns in the code based on given condition.\nFor example to search assert, suppress warnings patterns.\n\n```sh\nfrom functiondefextractor import condition_checker\nout_put = core_extractor.check_condition(\"@SupressWarning\", r\"path_to_excelfile/dataframe\", \"(\")\nprint(out_put[0], out_put[1])\n```\n\n### Commandline\n\n- General usage with out options to extract functions from repo.\n\n```sh\n\u003e\u003e\u003epython -m functiondefextractor --p \"path/to/repo\"\n```\n\n- To extract functions from repo having specific annotation.\n\n```sh\n\u003e\u003e\u003epython -m functiondefextractor --p \"path/to/repo\" --a \"@SuppressWarnings(\\\"UnusedReturnValue\\\")\"\n```\n\nNote: If annotation contains double quotes as part of annotation(like\nabove example) use backslash(\\) before double quote inside annotation.\n\n- To ignore files from repo using regex pattern.\n\n```sh\n\u003e\u003e\u003epython -m functiondefextractor --p \"path/to/repo\" --i '*.java, *.cpp'\n```\n\n- To analyse various patterns in the code based on given condition.\n\n```sh\n\u003e\u003e\u003epython -m functiondefextractor --c \"Assert\" --e \"path/to/excel\" --s \"(\"\n```\n\n- Help option can be found at,  \n\n```sh\n\u003e\u003e\u003epython -m functiondefextractor --h\n```\n\n### Sample use cases\n\n- To extract all functions from a repository\n\n```sh\n\u003e\u003e\u003epython -m functiondefextractor --p \"path/to/repo\"\n```\n\n```sh\nfrom functiondefextractor import core_extractor\nout_put = core_extractor.extractor (r\"path_to_repo/code\")\nprint(out_put)\n```\n\n- To extract all functions with \"@Test\" annotation\n  excluding all \".cpp\" files in the repository\n\n```sh\n\u003e\u003e\u003epython -m functiondefextractor --p \"path/to/repo\" --a \"@Test\" --i '*.cpp'\n```\n  \n```sh\nfrom functiondefextractor import core_extractor\nout_put = core_extractor.extractor(r\"path_to_repo/code\", annot=\"@Test\", exclude=r'*.cpp')\nprint(out_put)\n```\n\nNote:\n\n1. functionstartwith argument can be used to specifically extract code\nfrom required functions whose names starts with \"test_\" or what ever name\nuser is interested in.\n\n2. delta and annot arguments together can be used to extract required number\nof lines below and above the given annotation/keyword.\n\n- To analyze various patterns present in extracted code\n\n```sh\n\u003e\u003e\u003epython -m functiondefextractor --c \"Assert\" --e \"path/to/excel\" --s \"(\"\n```\n\n```sh\nfrom functiondefextractor import condition_checker\nout_put = core_extractor.check_condition(\"@SupressWarning\", r\"path_to_excelfile/dataframe\", \"(\")\nprint(out_put[0], out_put[1])\n```\n\n### Output\n  \n- Executing functiondefextractor to extract functions from\n command line would generate an output excel file which contains\n FileName_FunctionName in Unique ID column and extracted functions in Code column\n\n- Using functiondefextractor to extract functions from code would return\n a dataframe with same content as excel file.\n\n- When functiondefextractor is executed from script to analyse patterns in code,\n a tuple with 2 data frames would be generated which contains the requested pattern\n statements with their count in various functions and a pivot table of the\n same respectively.\n\n## Contact\n\n[MAINTAINERS.md](MAINTAINERS.md)  \n\n## License\n\n[License.md](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilips-software%2Ffunctiondefextractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilips-software%2Ffunctiondefextractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilips-software%2Ffunctiondefextractor/lists"}