Skip to content

Introduce Qodana analysis #4514

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

Merged
merged 3 commits into from
Apr 24, 2025
Merged

Introduce Qodana analysis #4514

merged 3 commits into from
Apr 24, 2025

Conversation

arturcic
Copy link
Member

This pull request includes significant updates to .editorconfig rules, introduces a new Qodana code quality workflow and configuration, and refactors various test files and the ArgumentParser class to improve code clarity and maintainability. Below is a summary of the most important changes:

Code Style and Analyzer Rule Updates:

  • Updated .editorconfig to adjust severity levels for various C# style rules, such as changing csharp_style_var_* rules from silent to suggestion. Removed several IDE and CA diagnostic rules, such as IDE0011 (add braces) and CA1825 (avoid zero-length array allocations). [1] [2]
  • Added ReSharper-specific rules, including resharper_csharp_use_roslyn_logic_for_evident_types and resharper_csharp_instance_members_qualify_members. [1] [2]

Qodana Code Quality Workflow:

  • Introduced a new Qodana code quality workflow in .github/workflows/qodana_code_quality.yml to integrate JetBrains Qodana into CI/CD pipelines. This includes branch-specific triggers and steps for setup and scanning.
  • Added a qodana.yaml configuration file to define inspection profiles and rules for Qodana analysis, enabling and excluding specific inspections.
  • Updated build/CI.slnx to include the qodana.yaml file and the new Qodana workflow. [1] [2]

Test Refactoring:

  • Updated test files to improve readability and consistency, such as replacing string concatenation with raw string literals and simplifying variable declarations. Examples include changes in ArgumentParserTests.cs, ExecCmdLineArgumentTest.cs, and VersionWriterTests.cs. [1] [2] [3]
  • Refactored test helper methods, such as modifying Run in ProgramFixture.cs to remove unnecessary array conversion.

ArgumentParser Improvements:

  • Simplified logic in ArgumentParser.cs by reducing unnecessary nesting and improving readability, such as combining single-line if statements and removing redundant code. [1] [2]
  • Improved error messages for invalid arguments, such as using string interpolation for better clarity.

Miscellaneous Changes:

  • Updated ExecutionResults in Helpers/ExecutionResults.cs to remove init accessors for properties that are initialized in the constructor.
  • Fixed a test assertion in UpdateWixVersionFileTests.cs to use Count instead of Count().

@arturcic arturcic added the build label Apr 24, 2025
@arturcic arturcic force-pushed the feature/qodana-analysis branch from cb14fc3 to 1d855e4 Compare April 24, 2025 02:35
@arturcic arturcic marked this pull request as ready for review April 24, 2025 03:24
@Copilot Copilot AI review requested due to automatic review settings April 24, 2025 03:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces Qodana analysis and various code quality improvements, alongside refactoring tests and the ArgumentParser to enhance clarity and maintainability. Key updates include:

  • Adjustments to editorconfig and analyzer rules, and the addition of ReSharper-specific configurations.
  • Integration of a new Qodana CI/CD workflow and configuration file.
  • Refactoring of test files and improvements in ArgumentParser logic.

Reviewed Changes

Copilot reviewed 234 out of 236 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/GitVersion.BuildAgents/Agents/EnvRun.cs Changed environment variable constant to private and streamlined condition checks.
src/GitVersion.BuildAgents/Agents/Drone.cs Reversed conditional logic for branch detection and standardized environment variable retrieval.
src/GitVersion.BuildAgents/Agents/BitBucketPipelines.cs Simplified string output and inline conditional logic for branch identification.
src/GitVersion.BuildAgents/Agents/AzurePipelines.cs Streamlined conditionals using ternary operators for branch/tag handling and build number updates.
src/GitVersion.BuildAgents/Agents/AppVeyor.cs Optimized branch retrieval using a ternary operator with environment variables.
src/GitVersion.App/QuotedStringHelpers.cs Adopted new C# raw array literal syntax for filtering split strings.
src/GitVersion.App/OverrideConfigurationOptionParser.cs Minor type declaration changes for improved consistency.
src/GitVersion.App/FileSystemGlobbing/DirectoryInfoGlobbingWrapper.cs Refactored file system enumeration and exception messaging.
src/GitVersion.App/ArgumentParser.cs Simplified target path parsing and switch handling logic.
src/GitVersion.App.Tests/* Various test refactorings including string literal updates and type adjustments.
qodana.yaml New Qodana configuration file defining inspection profiles and rules.
.github/workflows/qodana_code_quality.yml New GitHub workflow for running Qodana analysis on specified branches.
Files not reviewed (2)
  • .editorconfig: Language not supported
  • build/CI.slnx: Language not supported

Adds a Qodana workflow to analyze code quality.

Configures the workflow with .NET SDK setup, Qodana scan execution, and inspection profiles.
Integrates a baseline file for Qodana in the GitHub Actions workflow to compare analysis results against a predefined state. This helps to minimize noise by filtering out preexisting issues.
@arturcic arturcic force-pushed the feature/qodana-analysis branch from 1d855e4 to 0ec9f61 Compare April 24, 2025 03:25
@arturcic arturcic added this to the 6.2.x milestone Apr 24, 2025
@arturcic arturcic merged commit 70c0d9a into main Apr 24, 2025
185 checks passed
@arturcic arturcic deleted the feature/qodana-analysis branch April 24, 2025 08:19
Copy link
Contributor

mergify bot commented Apr 24, 2025

Thank you @arturcic for your contribution!

@gittools-bot
Copy link

🎉 This issue has been resolved in version 6.3.0 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants