R005: 组件尺寸使用固定值

Identifies fixed-width and fixed-height layouts in Knoxite Harmony UI codebases.

31|6|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill r005
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: R005: 组件尺寸使用固定值
Source: https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/check-test-code-quality/rules/R005
Command: npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill r005

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It detects UI components that use fixed width/height values, which makes pages hard to adapt across different devices and often causes downstream XTS adaptation issues.

Core Features & Use Cases

  • Covers all source code files: scans .ets, .ts, and .js files and explicitly avoids limiting analysis to test files.
  • Flags fixed numeric and pixel-like dimensions: detects .width(...) / .height(...) patterns with numeric literals and string literals such as 100px, 100vp, 200fp, 50lpx.
  • Avoids false positives: excludes percentage-based values like 50% and variable-based usages like .width(this.someVar).
  • Produces actionable findings: outputs rule id, severity, file/line, testcase association (or - for non-test files), and a targeted remediation suggestion.

Quick Start

Use the R005 rule to scan an OpenHarmony UI codebase and list every fixed width/height usage with file and line number so you can convert them to percentage-based or adaptive layouts.

Frequently Asked Questions about R005: 组件尺寸使用固定值

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find fixed width and height values in OpenHarmony UI code?

To find fixed width and height values in OpenHarmony UI code, scan .ets, .ts, and .js files to detect numeric and pixel-like dimensions like 100px or 100vp while excluding percentage and variable references.

Why do fixed UI dimensions cause XTS adaptation problems in OpenHarmony?

Fixed UI dimensions cause XTS adaptation problems because rigid pixel values break multi-device adaptability, making pages fail to scale correctly across different screen sizes.

Does static analysis for fixed dimensions exclude percentage-based values?

Static analysis for fixed dimensions excludes percentage-based values, avoiding false positives by ignoring valid adaptive layouts like 50% and variable-based usages.

What is the best way to scan ets files for hardcoded pixel dimensions?

The best way to scan ets files for hardcoded pixel dimensions is to run static analysis that flags .width() and .height() patterns containing numeric literals or strings like 200fp and 50lpx.

How are fixed dimension warnings reported for test files?

Fixed dimension warnings are reported as structured issue records tagged with rule R005 and Warning severity, providing file and line numbers alongside the nearest testcase association.