Code Quality Analysis with Huawei Cloud CodeArts
Code Quality Analysis with Huawei Cloud CodeArts
Hi there! This article explores the importance of code quality analysis with Huawei Cloud CodeArts Check Service and highlights the benefits it brings to the development process.
Introduction
Among Huawei Cloud CodeArts’ sub-services (Repo, Req, Check, Testplan, Perftest, Pipeline, Deploy, Build, Artifact), we are going to focus specifically on CodeArts Check service, where we can perform static code quality analysis and manage our DevOps process better. For software excellence, we need to understand the code quality metrics.
What is Code Quality?
Code quality is a best practice of checking your code in terms of maintainability, security, readability and performance with pre-defined rules. Benefits of code quality analysis include:
- Enhanced Reliability: By conducting code quality analysis, developers can uncover bugs, logic errors, and vulnerabilities, preventing potential system crashes and failures.
- Improved Maintainability: Well-structured and maintainable code is easier to understand, update, and debug. Code quality analysis helps identify complex and convoluted code segments, enabling developers to refactor and streamline the codebase.
- Performance Optimization: Code quality analysis tools often provide insights into performance bottlenecks, resource inefficiencies, and suboptimal algorithms.
- Security Enhancement: Code vulnerabilities, such as improper input validation, authentication flaws, or insecure data handling, can be exposed through quality analysis.
Also by using CodeArts Check service, you can effortlessly integrate your check process into your CI/CD Pipeline and choose the right code quality metrics from SonarQube, Codemars and among other built-in metrics.
Let’s see the best practices of CodeArts Check service!
Hands-on Experience
In this best practice, we are going to follow the below steps:
- Visiting CodeArts Check Service Dashboard
- Create a Check Task
- Select a Code Source
- Select and Prioritize Rulesets
- Advanced Settings
- Start Check Task
- See the Overview, Issues, Metrics and Logs
1. Visit CodeArts Check Service Dashboard
After you log-in to CodeArts Service, click Check Service on navigation bar. Then we will directly jump into creating a Check Task for our code repository.
2. Create a Check Task
In order to create a check task, click the blue “Create Task” button.
3. Select Code Source
If you already have a repository in CodeArts Repo service, you can directly select an existing repo.
If you plan to perform code quality check on an other git provider such as: Github, Gitlab, Bitbucket, you should add an endpoint and connect via http. When your repository appears on the page, click “New Task” and select your branch to be checked.
4. Select and Prioritize Rulesets
Once you see the task you have created, it is time for deciding the metrics for evaluating your code. Rulesets are the indicators of your code metrics. Go to “Settings” tab, click “Rule Sets” in the navigation bar. You will see a screen where CodeArts Check has already detected languages and automatically assigned your code a set of rulesets. You can either enable or disable the rule sets seen on the screen. Click “View Details” for customizing rule sets.
You can see filters metrics according to status, priority, owner and so forth… On the right panel, you can select new rules to be considered in your code check process and search for rules by rule names. Also you can set your Issue Level Priorities on the most right dropdown menu.
5. Advanced Settings
Before you start your check process, there are several things to consider. At first, you may exclude unnecessary files by checkboxes.
You can also set the code quality process’ definition of success. You can set your quality gate values simply by inputting the number of faults by priority you can tolerate.
You can create an execution plan manually by scheduling.
You can send notification and e-mails to selected roles and members by event triggers.
You can arrange the Chceck range by choosing in between only changed files or full code.
You can trigger this check task by commits and changes. Note that the difference between Continous Integration and CodeArts Repo(Proactive Review) option is: Code Check is triggered by any Merge Request in Proactive Review while code check is triggered by commits in Continous integration.
6. Start Check Task
Once you are done configuring and saving, click the “Start Check” button.
Wait for progress to be finished. When your code quality check process finishes, you will see the following Overview dashboard:
Let’s have a look at the other tabs:
In the issues tab, you can filter through rule priorities and tags on the left panel. On the right panel, you can investigate fault by fault. When you click “Create Report”, it generates a PDF copy of this code check task.
When you click “All Change”, you can change the owner of this fault and assign a new task in your project management dashboard. You can change fault’s status to “resolved” also.
When you go to Metrics tab, you can see each metric you have chosen at the beginning and the distribution of faults under each metric.
When you visit Logs page, you can see the recorded logs step-by-step.
Congrats! Now you know how to perform O&M on code quality analysis with Huawei Cloud’s CodeArts Check Service.
Conclusion
Code quality analysis is an indispensable practice that enables developers to deliver robust, maintainable, and secure software solutions. By leveraging automated tools such as Huawei Cloud CodeArts Check, developers can detect and rectify potential issues early in the development cycle. This approach enhances reliability, performance, and maintainability while reducing technical debt and improving overall software excellence. Embracing code quality analysis as an integral part of the development process leads to higher-quality software that meets user expectations and withstands the challenges of today’s rapidly evolving technological landscape.