{"id":17349067,"url":"https://github.com/arturwincenciak/resharper_cleanupcode_demo","last_synced_at":"2025-08-01T22:32:44.998Z","repository":{"id":85783227,"uuid":"585123247","full_name":"ArturWincenciak/ReSharper_CleanupCode_Demo","owner":"ArturWincenciak","description":"Usage a GitHub Action that allows you to run ReSharper's CleanupCode Command-Line Tool in order to automatically apply code style rules and reformat code in a project","archived":false,"fork":false,"pushed_at":"2024-06-19T13:10:37.000Z","size":1592,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-16T18:12:06.691Z","etag":null,"topics":["bash","bash-script","clean-code","cleanup","cleanup-code","cleanup-script","csharp","csharp-code","dotnet","dotnet-core","git","github-action","github-actions","jetbrains","jetbrains-command-line-tool","jetbrains-toolbox","lint","linter","resharper","resharper-command-line-tool"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/resharper-cli-cleanupcode","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ArturWincenciak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-01-04T11:29:39.000Z","updated_at":"2024-09-24T03:22:21.000Z","dependencies_parsed_at":"2024-04-02T18:47:02.033Z","dependency_job_id":"13487698-608e-46f9-bb93-18e7fe141e3b","html_url":"https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturWincenciak%2FReSharper_CleanupCode_Demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturWincenciak%2FReSharper_CleanupCode_Demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturWincenciak%2FReSharper_CleanupCode_Demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArturWincenciak%2FReSharper_CleanupCode_Demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArturWincenciak","download_url":"https://codeload.github.com/ArturWincenciak/ReSharper_CleanupCode_Demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228413782,"owners_count":17915908,"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":["bash","bash-script","clean-code","cleanup","cleanup-code","cleanup-script","csharp","csharp-code","dotnet","dotnet-core","git","github-action","github-actions","jetbrains","jetbrains-command-line-tool","jetbrains-toolbox","lint","linter","resharper","resharper-command-line-tool"],"created_at":"2024-10-15T16:54:34.722Z","updated_at":"2024-12-06T04:41:27.064Z","avatar_url":"https://github.com/ArturWincenciak.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  ReSharper CLI CleanupCode GitHub Action Demo\n\n\u003e ### Visit the blog post to read more about the context of use cases\n\u003e [Zaoszczędź swój czas, niech kod wyczyści się sam – ReSharper CLI CleanupCode GitHub Action](https://teo-vincent.blog/2023/12/31/zaoszczedz-swoj-czas-niech-kod-wyczysci-sie-sam-resharper-cli-cleanupcode-github-action/)\n\n#### Action in Marketplace: [ReSharper CLI CleanupCode](https://github.com/marketplace/actions/resharper-cli-cleanupcode)\n#### Action in Repository: [ArturWincenciak/ReSharper_CleanupCode@v2.0](https://github.com/ArturWincenciak/ReSharper_CleanupCode)\n\n## Try your self\n1. Fork this repo\n2. Create a Pull Request\n3. Go to `Actions` and observe the action in action\n4. Check out history of your repo and see newly created commit\n\n## Brief\n\nThat is a project uses a GitHub Action that allows you to run \n[ReSharper's CleanupCode Command-Line Tool](https://www.jetbrains.com/help/resharper/CleanupCode.html) in order to\nautomatically apply code style rules and reformat code in a project. The action is triggered on a push event, and it\ncleans up the code using the specified profile, and commits the changes with a specified commit message.\n\nNote that this code includes an example class `DemoClass` that breaks some style rules and a unit test class `DemoUnitTests`, \nwhich also breaks rules but is used to demonstrate how the action can be configured to exclude certain types of code from being \ncleaned up.\n\n## Usage [cleanup_code.yml](https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo/blob/main/.github/workflows/cleanup_code.yml)\n\n\n```yaml\nname: ReSharper CLI CleanupCode\n\non: [ push ]\n\njobs:\n  cleanup:\n    runs-on: ubuntu-latest\n    name: Cleanup Code\n    \n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Setup .NET\n        uses: actions/setup-dotnet@v3\n        with:\n          dotnet-version: 7.0.x\n\n      - name: Restore Dependencies\n        run: dotnet restore ReSharperCleanupCodeDemo.sln\n          \n      - name: Cleanup Code\n        id: cleanup\n        uses: ArturWincenciak/ReSharper_CleanupCode@v4.14\n        with:\n          solution: 'ReSharperCleanupCodeDemo.sln'\n          fail_on_reformat_needed: 'no'\n          jb_cleanup_code_arg: '--verbosity=INFO --profile=Built-in: Full Cleanup --exclude=**UnitTests/**.*'\n```\n### Here you have sequence of steps\n\n- `Checkout`: download the source code from the current repository where the Action was\n  initiated\n- `Setup .NET`: install the specified version of .NET on the virtual machine where the Action is run\n- `Restore Dependencies`: restore all project dependencies, such as NuGet libraries\n- **`Cleanup Code`: clean up the code action**\n\nThe last step, named **`Cleanup Code`**, is the one that is most relevant to us here.\n\n### Configure the command-line tool parameters\n\nUsing action input `jb_cleanup_code_arg` for instance like down below\nyou can configure CleanupCode with command-line parameters as it is described\nhere in **[clear and concise specification](https://www.jetbrains.com/help/resharper/CleanupCode.html#command-line-parameters)**.\n\n```yaml\njb_cleanup_code_arg: '--verbosity=INFO --profile=Almost Full Cleanup --exclude=**UnitTests/**.*'\n```\nHere has been used `--exclude` parameter to exclude unit test code from being cleaned up and `--profile` to choose\non of my custom configuration stored in team shared `ReSharperCleanupCodeDemo.sln.DotSettings` settings.\n\n## The simplest way to usage\n\n```yaml\nsteps:\n  - name: Cleanup Code\n    uses: ArturWincenciak/ReSharper_CleanupCode@v2.0\n    with:\n      solution: 'ReSharperCleanupCodeDemo.sln'\n```\n\n**To learn more, please visit [specification in the marketplace](https://github.com/marketplace/actions/resharper-cli-cleanupcode).**\n\n## Shared team configuration\n\n### Solution team-shared settings in `*.sln.DotSettings`\n\nAll your settings should be saved in \n[Solution Team-Shared Layer](https://www.jetbrains.com/help/rider/Sharing_Configuration_Options.html#solution-team-shared-layer)\nyou can find this project here in that file \n[ReSharperCleanupCodeDemo.sln.DotSettings](https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo/blob/main/ReSharperCleanupCodeDemo.sln.DotSettings).\n\n### Export code style settings to `.editorconfig`\n\nRead more here:\n- [Use EditorConfig](https://www.jetbrains.com/help/rider/Using_EditorConfig.html)\n- [Export code style settings to EditorConfig](https://www.jetbrains.com/help/rider/Using_EditorConfig.html#export-code-style-settings)\n\nI suggest exporting all settings, including default settings, to a [.editorconfig](https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo/blob/main/.editorconfig) file. It is important to explicitly\nsave all default settings to avoid potential issues in the future caused by changes in default settings in newer\nversions of the command-line tool software. It is important to explicitly save all default settings in a transparent manner.\n\n### Set up your `--profile`\n\nRead more here: \n- [Code cleanup profiles ](https://www.jetbrains.com/help/rider/2022.3/Code_Cleanup__Index.html#profiles)\n\nAs you can see in the [cleanup_code.yaml](https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo/blob/main/.github/workflows/cleanup_code.yml) file:\n\n```yaml\njb_cleanup_code_arg: '--verbosity=INFO --profile=Almost Full Cleanup --exclude=**UnitTests/**.*'\n```\n\none of the settings is the `--profile` flag. I have set my profile to be named `Almost Full Cleanup`.\n\nI have configured my profile to exclude `*.md` files and the `.editorconfig` file from the cleaning up.\n\n![Code Cleanup Profiles](assets/code_cleanup_profiles.png)\n\n### Set up your type layout patterns\n\nRead more here:\n- [Rearrange members with file and type layout patterns](https://www.jetbrains.com/help/rider/File_and_Type_Layout.html)\n\nMy current favorite setting\n[ReSharperCleanupCodeDemo.sln.DotSettings](https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo/blob/main/ReSharperCleanupCodeDemo.sln.DotSettings)\nlooks like that:\n\n![Code Cleanup File Layout](assets/code_cleanup_file_layout.png)\n\n## Clean up your code in local repo\n\n- **[local-dev-cleanup-code.sh](https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo/blob/main/local-dev-cleanup-code.sh)**\n\nIn this repository I have prepared a ready-made script `local-dev-cleanup-code.sh` that you can run locally. \nThat script will perform clean up code and create a commit with the changes in your local repository.\n\nThis is an additional feature that allows you to push the commit to the remote repository by your self and avoiding the\nneed to `pull` automatically created commit on the remote repository. This can save you the hassle of resolving conflicts \nin case you have made changes to the same file locally in the meantime.\n\nThis will save your time from having to enter a commit message each time. \nThe commit with the changes will be created automatically.\n\nFeel free to use the script and perform clean up your code locally with a fully automated commit and save your time.\n\n\u003e _This script can be attached to the git hooks, however, attaching this script to the `pre-commit` git hook is\nnot advisable as it may slow down our work considerably due to the lengthy clean up code process. It may be more\nbeneficial to add this script to the `pre-push` git hook instead._\n\n### How to run the script \n\nFirst of all remember to add the required \n[manifest file](https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo/blob/main/.config/dotnet-tools.json) \nand then run that commands:\n\n```bash\ndotnet tool restore\ndotnet tool update --global JetBrains.ReSharper.GlobalTools\nsource .bashrc\n```\n\n### Next time you can just call\n\n```bash\ncc\n```\n### Clean up code and leave the changes in your working copy without commit\n\n```bash\ncc -a no\n```\n\n# Cleanup Code works perfectly with Inspect Code\n\nThere are situations where Cleanup Code does not do the entire job for us, but we can still greatly help ourselves and\nspeed up ours Code Review process by adding an additional automatic step that performs an inspection of the code and,\nadds a comments to the submitted Pull Request on our behalf.\n\nDown below, I demonstrate how to combine [ReSharper CLI CleanupCode](https://github.com/marketplace/actions/resharper-cli-cleanupcode) \nand [ReSharper CLI InspectCode](https://github.com/marketplace/actions/resharper-cli-inspectcode) using \n[GitHub Action](https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo/blob/main/.github/workflows/cleanup_code.yml)\nthat contains two jobs: `cleanup` and `inspection`.\n\n- **Marketplace: [ReSharper CLI CleanupCode](https://github.com/marketplace/actions/resharper-cli-cleanupcode)**\n  - _that one I've created by my self_\n- **Marketplace: [ReSharper CLI InspectCode](https://github.com/marketplace/actions/resharper-cli-inspectcode)**\n  - _that one I've found in the Marketplace and used it here, it was an inspiration for me to create my own action up above_\n\n```yaml\nname: ReSharper CLI CleanupCode\n\non: [ push ]\n\njobs:\n  cleanup:\n    runs-on: ubuntu-latest\n    name: Cleanup Code\n    \n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Setup .NET\n        uses: actions/setup-dotnet@v3\n        with:\n          dotnet-version: 7.0.x\n\n      - name: Restore Dependencies\n        run: dotnet restore ReSharperCleanupCodeDemo.sln\n          \n      - name: Cleanup Code\n        id: cleanup\n        uses: ArturWincenciak/ReSharper_CleanupCode@v2.0\n        with:\n          solution: 'ReSharperCleanupCodeDemo.sln'\n          fail_on_reformat_needed: 'no'\n          jb_cleanup_code_arg: '--verbosity=INFO --profile=Almost Full Cleanup --exclude=**UnitTests/**.*'\n  \n  inspection:\n    runs-on: ubuntu-latest\n    name: Inspect Code\n    needs: cleanup\n\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Setup .NET\n        uses: actions/setup-dotnet@v3\n        with:\n          dotnet-version: 7.0.x\n\n      - name: Restore Dependencies\n        run: dotnet restore ReSharperCleanupCodeDemo.sln\n\n      - name: Inspect code\n        uses: muno92/resharper_inspectcode@1.6.5\n        with:\n          solutionPath: ./ReSharperCleanupCodeDemo.sln\n          failOnIssue: 1\n          minimumSeverity: notice\n          solutionWideAnalysis: true\n```\n---\n\nLet's look at the following screenshots to see how the jobs have been configured and utilized in this project.\n\n## Branch protection rule\n![Branch protection rule](assets/code_cleanup_branch_protection_rule.png)\n\n## Cleanup job is in progress\n![Cleanup job in progress](assets/code_cleanup_pr_action_jobs_first_in_progress.png)\n\n## Cleanup job is done \n![Cleanup job done](assets/code_cleanup_pr_action_jobs_second_in_progress.png)\n\n## Commit has been made and pushed into the branch by the Cleanup job\n![Commit has been made and pushed into the branch by the Cleanup job](assets/code_cleanup_pr_auto-commit_v2.png)\n\n## Details of the auto-commit \n![Details of the auto-commit](assets/code_cleanup_pr_auto-commit-review_v2.png)\n\n## Inspection job is in progress\n![Inspection job in progress](assets/code_cleanup_pr_action_jobs_second_in_progress.png)\n\n## Inspection job is done\n![Inspection job done](assets/code_cleanup_pr_action_jobs_second_result.png)\n\n## Review code has been made by the Inspection job\n![Review code has been made by the Inspection job](assets/code_cleanup_pr_files_changes_v2.png)\n\n## Pull Request checks were not successful\n![Pull Request checks were not successful](assets/code_cleanup_pr_checks_were_no_successful.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturwincenciak%2Fresharper_cleanupcode_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farturwincenciak%2Fresharper_cleanupcode_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturwincenciak%2Fresharper_cleanupcode_demo/lists"}