Code Quality Analysis with Huawei Cloud CodeArts

Enes Çetinberk
Huawei Developers
Published in
6 min readJul 6, 2023
Huawei Cloud CodeArts Logo

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:

  1. Visiting CodeArts Check Service Dashboard
  2. Create a Check Task
  3. Select a Code Source
  4. Select and Prioritize Rulesets
  5. Advanced Settings
  6. Start Check Task
  7. See the Overview, Issues, Metrics and Logs

1. Visit CodeArts Check Service Dashboard

CodeArts Check 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

CodeArts Repo Choice

If you already have a repository in CodeArts Repo service, you can directly select an existing repo.

Other Git Providers

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

Rule Set Page

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.

Prioritization of 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

Excluded Files

Before you start your check process, there are several things to consider. At first, you may exclude unnecessary files by checkboxes.

Quality Gate

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.

Scheduled Check

You can create an execution plan manually by scheduling.

Notifications

You can send notification and e-mails to selected roles and members by event triggers.

MR Check

You can arrange the Chceck range by choosing in between only changed files or full code.

Triggering Code Check

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

Start Check

Once you are done configuring and saving, click the “Start Check” button.

Progress Bar

Wait for progress to be finished. When your code quality check process finishes, you will see the following Overview dashboard:

Overview-1
Overview-2

Let’s have a look at the other tabs:

Issues Tab

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.

All Change Button

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.

Metrics

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.

Logs

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.

Resources

--

--