logo资料库

Sonar参数分析.docx

第1页 / 共18页
第2页 / 共18页
第3页 / 共18页
第4页 / 共18页
第5页 / 共18页
第6页 / 共18页
第7页 / 共18页
第8页 / 共18页
资料共18页,剩余部分请下载后查看
Sonar参数分析
API compatibility
1.API behavior changes---Clirr Plugin
2.API breaks---Clirr Plugin
3.New API---Clirr Plugin
4.Total API Changes---Clirr Plugin
Architecture
5.Architecture--- Total Quality Plugin
6.Architecture Tangle Index--- Total Quality Plugin
Complexity
7.Complexity—默认
8.Complexity /class—默认
9.Complexity /file—默认
10.Complexity /method—默认
11.Complexity Factor--- Quality Index Plugin
12.Complexity Factor Methods--- Quality Index Plugin
13.QI Complexity---Quality Index Plugin
Design
14.Design Classes and Methods Complexity--- Total Qua
15.Design Coupling Between Objects--- Total Quality P
16.Design Depth of Inheritance Tree--- Total Quality
17.Design Lack of Cohesion of Methods--- Total Qualit
18.Design Response for Class--- Total Quality Plugin
19.Design Quality--- Total Quality Plugin
20.LCOM4(Lack of cohesion of methods)
21.Package tangle index
22.RFC(Response for Class)
23.Suspect LCOM4 density
Documentation
24.Comment lines
25.Commented-out LOC
26.Comments (%)
27.Public documented API (%)
28.Public undocumented API
Duplication
29.DRYness –-- Total Quality Plugin
30.Duplicated blocks
31.Duplicated files
32.Duplicated lines
33.Duplicated lines (%)
34.Useless Duplicated Lines---Useless Code Tracker
General
35.Analysability Value--- SIG Maintainability Model
36.Changeability Value--- SIG Maintainability Model
37.Stability Value--- SIG Maintainability Model
38.Testability Value--- SIG Maintainability Model
39.Profile version未知
40.Quality Index--- Quality Index Plugin
41.SIG MM-- SIG Maintainability Model
42.Technical Debt ($)---Technical Debt Plugin
43.Technical Debt in days---Technical Debt Plugin
44.Technical Debt ratio---Technical Debt Plugin
45.Total Quality--- Total Quality Plugin
Management
46.Burned budget
47.Business value
48.Team size
Rules
49.Blocker violations
50.Code Quality--- Total Quality Plugin
51.Critical violations
52.Dead Code--- Useless Code Tracker
53.Info violations
54.Major violations
55.Minor violations
56.Potential Dead Code--- Useless Code Tracker
57.QI Coding Violations---Quality Index Plugin
58.QI Coding Weighted Violations---Quality Index Plug
59.QI Style Violations---Quality Index Plugin
60.QI Style Weighted Violations---Quality Index Plugi
61.Rules compliance
62.Security rules compliance--- Security Rules Plugin
63.Security violations--- Security Rules Plugin
64.Violations
65.Weighted Security Violations--- Security Rules Plu
Size
66.Accessors
67.Artifact Size (Kb)--- Artifact Size Plugin
68.Classes
69.Files
70.Lines
71.Lines of code
72.Methods
73.Packages
74.Public API
75.Statements
76.Total Useless Code-- Useless Code Tracker
Tests
77.Coverage
78.Line coverage
79.QI Test Coverage---Quality Index Plugin
80.Skipped unit tests
81.Testing Quality--- Total Quality Plugin
82.Uncovered lines
83.Unit test errors
84.Unit test failures
85.Unit test success (%)
86.Unit tests
87.Unit tests duration
SCM
88.Commits
89.Last commit
SQALE
90.SQALE Rating
91.SQALE Remediation Cost
附录
92.Sonar插件
93.Sonar帮助文档中的度量值
Sonar 参数分析 API compatibility 1. API behavior changes---Clirr Plugin 正常接口变化数 2. API breaks---Clirr Plugin 可能引发错误的接口变化 3. New API---Clirr Plugin 新增接口数 4. Total API Changes---Clirr Plugin 接口变化总数 注:以上参数需要依赖于 Clirr,暂时仍存在问题 Architecture 5. Architecture--- Total Quality Plugin 架构质量 计算方式: ARCH = 100 – TI TI = Tangle Index 6. Architecture Tangle Index--- Total Quality Plugin 架构复杂指标 Complexity 7. Complexity—默认 复杂度 8. Complexity /class—默认 类复杂度 9. Complexity /file—默认 文件复杂度 10. Complexity /method—默认 方法复杂度 11. Complexity Factor--- Quality Index Plugin 复杂度因素 计算方式: CF = (5 * Complexity>30) * 100 / (Complexity>1 + Complexity>10 + Complexity>20 +
Complexity>30) 12. Complexity Factor Methods--- Quality Index Plugin 方法复杂度因素 13. QI Complexity---Quality Index Plugin 复杂度质量指标 计算方式: (Complexity>30 *10 + Complexity>20 * 5 + Complexity>10 * 3 + Complexity>1) / validLines Design 14. Design Classes and Methods Complexity--- Total Quality Plugin NOM = (1 - (class_complexity - 12) / (acel * 12)) * 50 + (1 - (method_complexity - 2.5) / (acel * 2.5)) * 50 参见 19 15. Design Coupling Between Objects--- Total Quality Plugin CBO = (1 - (efferent_coupling - 5) / (acel * 5)) * 100 参见 19 16. Design Depth of Inheritance Tree--- Total Quality Plugin DIT = (1 - (depth_of_inheritance_tree - 5) / (acel * 5)) * 100 参见 19 17. Design Lack of Cohesion of Methods--- Total Quality Plugin LCOM = (1 - (lack_of_cohesion_of_method - 1) / (acel * 1)) * 100 参见 19 18. Design Response for Class--- Total Quality Plugin RFC = (1 - (response_for_class - 50) / (acel * 50)) * 100 参见 19 19. Design Quality--- Total Quality Plugin 设计质量 计算方式: DES = 0.15*NOM + 0.15*LCOM + 0.25*RFC 0.25*CBO + 0.20*DIT NOM = (1 - (class_complexity - 12) / (acel * 12)) * 50 + (1 - (method_complexity - 2.5) / (acel * 2.5)) * 50 LCOM = (1 - (lack_of_cohesion_of_method - 1) / (acel * 1)) * 100 RFC = (1 - (response_for_class - 50) / (acel * 50)) * 100 CBO = (1 - (efferent_coupling - 5) / (acel * 5)) * 100 DIT = (1 - (depth_of_inheritance_tree - 5) / (acel * 5)) * 100 Acel 参数因子的值可以在Sonar setting 页面配置。 每一个度量标准的默认阙值也可以进行配置(例如,50 是response_for_class 的默认阈值)。 20. LCOM4(Lack of cohesion of methods) 用来说明 class 内部方法和变量之间的关系, 值越大, 说明内聚性越差. 一般情况下 LCOM4=1 是内聚性最佳的. 2 说明可以拆成两个类, 以此类推.但是这种测量对门面服务类来 说不适用. 有时候很小的类也会根据需要合并在一起, 尽管关联不大 21. Package tangle index 包复杂指数 此参数为包的复杂等级,最好的值为 0%,意味着包之间没有圈依赖;最差的值为 100%, 意 味 着 包 与 包 之 间 的 关 系 特 别 的 复 杂 。 该 指 数 的 计 算 公 式 : 2 * (package_tangles / package_edges_weight) * 100.
22. RFC(Response for Class) 通过检查一个方法被调用的情况来反映一个 class 的复杂程度. 也可以简单的理解为一 个类所包含的方法多寡. 23. Suspect LCOM4 density LCOM4 密度值 Documentation 24. Comment lines Javadoc、多行注释、单行注释的总数。空注释行、头文件中的注释(主要用于定义许 可证)以及 commented-out 行均不会包括在内。 25. Commented-out LOC 注释掉的代码行数。Javadoc 块不会被扫描 26. Comments (%) 注释行数/(注释行数+有效代码行数) 27. Public documented API (%) 添加注释的公有 API 占总的公有 API 的百分比 28. Public undocumented API 公有 API 未添加注释个数 Duplication 29. DRYness –-- Total Quality Plugin DRYNESS = 100 - Duplicated lines density 30. Duplicated blocks 重复块数 31. Duplicated files 重复文件数 32. Duplicated lines 重复行数 33. Duplicated lines (%) 重复行占总行数的百分比 34. Useless Duplicated Lines---Useless Code Tracker 无用的重复行数;当前的 Sonar 告诉你有 50 重复的行数,但是不能告诉你是有两块 25 行的代码重复(这样你可以节省 25 行代码)还是有 5 块 10 行(这样你可以节省 40 行 代码)的代码重复;通过这个插件,你可以获取到额外的信息。 General 35. Analysability Value--- SIG Maintainability Model
可理解性 请查看 37 指标后的详细介绍 36. Changeability Value--- SIG Maintainability Model 可扩展性 37. Stability Value--- SIG Maintainability Model 稳定性 38. Testability Value--- SIG Maintainability Model 可测试性 可维护性可通过 7 个质量特性来衡量: 可理解性 可测试性 可修改性 可靠性 可移植性 可使用性 效率 这个插件标示了一个 Software Improvement Group(SIG)可维护性模型 这个模型需要两步: 计算基数的指标,然后结合他们计算出更高层面上的数值。 每一个指标被分成 5 级别排名:从--(很糟糕)到++(非常好) 第一步加上基数的指标。 Volume: 基于代码的行数 Rank LOC -- - 0 + ++ Duplications: 基于代码重复的密度 > 1310000 > 655000 > 246000 > 66000 > 0 Unit tests: 基于单元测试覆盖率 Rank Duplication -- - 0 + ++ > 20% > 10% > 5% > 3% > 0% Rank Coverage ++ + 0 > 95% > 80% > 60%
- -- > 20% > 0% Complexity:基于方法的圈复杂度 第一步根据圈复杂度的范围确定在方法代码行中的百分比。 Complexity Eval Very high > 50 High > 20 Medium > 10 Low > 0 然后根据分布,我们使用下面的表格来计算等级: Rank Medium High Very High ++ + 0 - < 0% < 0% < 5% < 0% < 10% < 0% < 15% < 5% < 25% < 30% < 40% < 50% 否则等级是-- Unit size: 基于方法代码的行数 第一步根据行数的范围确定方法代码行数的百分比。 Eval LOCs Very high > 100 High > 50 Medium > 10 Low > 0 然后根据分布,使用下面的表格来计算等级: Rank Medium High Very High ++ + 0 - < 0% < 0% < 5% < 0% < 10% < 0% < 15% < 5% < 25% < 30% < 40% < 50% 否则等级为-- 第二步是通过一个简单的平均,将他们结合起来,使用以下映射表来确定最终等级. Volume Complexity Duplications Unit size Unit tests analysability changeability stability
testability 因此 4 个代表软件可维护性四维的先进指标。 可选项,通过将 4 个指标简单的结合在一块,可以得到可维护性排名。 需要注意的是,图表的颜色代表实际结合后的值,从红色=--到绿色=++. 39. Profile version 未知 未知 40. Quality Index--- Quality Index Plugin 计算方式: QI = 10 - 4.5 * coding - 2 * complexity - 2 * coverage -1.5 * style 41. SIG MM-- SIG Maintainability Model SIG 可维护性模型,参考 37 42. Technical Debt ($)---Technical Debt Plugin 清除所有技术债务需要的花费 43. Technical Debt in days---Technical Debt Plugin 需要多少人日去解决技术债务 44. Technical Debt ratio---Technical Debt Plugin 技术债务占整个项目的比例 45. Total Quality--- Total Quality Plugin 总体质量 计算方式: TQ= 0.25*ARCH + 0.25*DES + 0.25*CODE + 0.25*TS Management 46. Burned budget 燃尽预算 47. Business value 商业价值 48. Team size 团队规模 注:以上变量为手动输入变量,另外这里可以添加一些自定义的变量
Rules 49. Blocker violations 阻碍性违规 50. Code Quality--- Total Quality Plugin 代码质量 计算方式: Code = 0.15*DOC + 0.45*RULES + 0.40*DRYNESS DOC = Documented API density RULES = Rules compliance index DRYNESS = 100 - Duplicated lines density 51. Critical violations 严重违规 52. Dead Code--- Useless Code Tracker 无作用程序代码 53. Info violations 建议级别违规 54. Major violations 重要违规 55. Minor violations 次要违规 56. Potential Dead Code--- Useless Code Tracker 当前代码中未使用的 protected 方法数目;此参数可通过 PMD :UnusedProtectedMethod 或者 SQUID:UnusedProtectedMethod 获取到。计算他们行数的和值。 57. QI Coding Violations---Quality Index Plugin 代码违规质量指标(PMD 规则指数) 计算方式: (Blocker * 10 + Critical * 5 + Major * 3 + Minor + Info) / validLines 58. QI Coding Weighted Violations---Quality Index Plugin 代码违规权重指标 59. QI Style Violations---Quality Index Plugin 风格违规质量指标(CheckStyle 规则指数) 计算方式: Style = (Errors*10 + Warnings) / ValidLines * 10 QI = 10 - 4.5 * coding - 2 * complexity - 2 * coverage -1.5 * style 60. QI Style Weighted Violations---Quality Index Plugin 风格违规权重质量指标 61. Rules compliance 遵守规则率 62. Security rules compliance--- Security Rules Plugin Security 规则遵守率 63. Security violations--- Security Rules Plugin 符合 Security 规则数目
64. Violations 违规总数 65. Weighted Security Violations--- Security Rules Plugin Security 规则权重值(总数) Size 66. Accessors Getter 及 setter 方法的数量 // Getters public String getName(){ return this.name; } public boolean isParent(){ return this.isParent; } // Setters public void setName(String name){ this.name = name; } public void setIsParent(boolean isParent){ this.isParent = isParent; } 67. Artifact Size (Kb)--- Artifact Size Plugin 记录最终产品大小 68. Classes 类总数 69. Files 文件数 70. Lines 文件中行数 71. Lines of code 代码行数 72. Methods 方法数目 73. Packages 包数目 74. Public API 公共类、公共方法(不包括访问器)以及公共属性(不包括 public final static 类型的) 的数目。 75. Statements Java 语言规范中没有块定义的语句数目;此数目在遇到含有 if, else, while, do, for, switch, break, continue, return, throw, synchronized, catch, finally 等关键字的语句时增加。例如:
分享到:
收藏