/[eiffelstudio]/branches/eth/eve/Src/framework/code_analysis/ca_code_analyzer.e
ViewVC logotype

Contents of /branches/eth/eve/Src/framework/code_analysis/ca_code_analyzer.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 93177 - (show annotations)
Mon Oct 28 22:16:38 2013 UTC (6 years ago) by zurfluhs
File size: 3712 byte(s)
Code Analysis:

- formatted version of rule violation description
- refactorings and other minor changes
1 note
2 description: "Summary description for {CA_CODE_ANALYZER}."
3 author: "Stefan Zurfluh"
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 CA_CODE_ANALYZER
9
10 inherit {NONE}
11 SHARED_EIFFEL_PROJECT
12
13 create
14 make
15
16 feature {NONE} -- Initialization
17
18 make
19 -- Initialization for `Current'.
20 do
21 create settings
22 create rules.make
23 -- Adding example rules
24 rules.extend (create {CA_SELF_ASSIGNMENT_RULE}.make)
25 rules.extend (create {CA_UNUSED_ARGUMENT_RULE}.make)
26
27 create classes_to_analyze.make
28 create rule_violations.make (100)
29 end
30
31 feature -- Analysis interface
32
33 analyze
34 local
35 l_rules_checker: CA_ALL_RULES_CHECKER
36 do
37 create l_rules_checker.make
38 across rules as l_rules loop
39 if l_rules.item.is_enabled then -- important: only add enabled rules
40 if system_wide_check or else (not l_rules.item.is_system_wide) then
41 -- do not add system wide rules if we check only parts of the system
42 l_rules.item.prepare_checking (l_rules_checker)
43 end
44 end
45 end
46
47 across classes_to_analyze as l_classes loop
48
49 -- TODO: more elegant and performant solution?
50 across rules as l_rules loop
51 l_rules.item.set_checking_class (l_classes.item)
52 end
53
54 l_rules_checker.run_on_class (l_classes.item)
55
56 rule_violations.extend (create {SORTED_TWO_WAY_LIST[CA_RULE_VIOLATION]}.make, l_classes.item)
57 end
58
59 across rules as l_rules loop
60 across l_rules.item.violations as l_v loop
61 rule_violations.at (l_v.item.affected_class).extend (l_v.item)
62 end
63 end
64
65 clear_classes_to_analyze
66 ensure
67 violation_list_exists: analysis_successful implies rule_violations /= Void
68 end
69
70 clear_classes_to_analyze
71 do
72 classes_to_analyze.wipe_out
73 end
74
75 add_whole_system
76 local
77 l_groups: LIST [CONF_GROUP]
78 l_cluster: CLUSTER_I
79 do
80 from
81 l_groups := eiffel_universe.groups
82 l_groups.start
83 until
84 l_groups.after
85 loop
86 l_cluster ?= l_groups.item_for_iteration
87 -- Only load top-level clusters, as they are loaded recursively afterwards
88 if l_cluster /= Void and then l_cluster.parent_cluster = Void then
89 add_cluster (l_cluster)
90 end
91 l_groups.forth
92 end
93
94 system_wide_check := True
95 end
96
97 add_cluster (a_cluster: CLUSTER_I)
98 local
99 l_conf_class: CONF_CLASS
100 l_class_i: CLASS_I
101 do
102 system_wide_check := False
103
104 from
105 a_cluster.classes.start
106 until
107 a_cluster.classes.after
108 loop
109 l_conf_class := a_cluster.classes.item_for_iteration
110 l_class_i := eiffel_universe.class_named (l_conf_class.name, a_cluster)
111 add_class (l_class_i)
112 a_cluster.classes.forth
113 end
114 if a_cluster.sub_clusters /= Void then
115 from
116 a_cluster.sub_clusters.start
117 until
118 a_cluster.sub_clusters.after
119 loop
120 add_cluster (a_cluster.sub_clusters.item_for_iteration)
121 a_cluster.sub_clusters.forth
122 end
123 end
124 end
125
126 add_classes (a_classes: ITERABLE[CLASS_I])
127 do
128 system_wide_check := False
129
130 across a_classes as l_classes loop
131 add_class (l_classes.item)
132 end
133 end
134
135 add_class (a_class: CLASS_I)
136 local
137 l_class_c: CLASS_C
138 do
139 system_wide_check := False
140
141 if a_class.is_compiled then
142 l_class_c := a_class.compiled_class
143 check l_class_c /= Void end
144 print ("Analyzing class " + a_class.name + "...%N")
145 classes_to_analyze.extend (l_class_c)
146 else
147 print ("Class " + a_class.name + " not compiled (skipped).%N")
148 end
149 end
150
151 feature -- Properties
152
153 analysis_successful: BOOLEAN
154
155 rules: LINKED_LIST[CA_RULE]
156
157 rule_violations: detachable HASH_TABLE[SORTED_TWO_WAY_LIST[CA_RULE_VIOLATION], CLASS_C]
158
159 feature {NONE} -- Implementation
160
161 settings: CA_SETTINGS
162
163 classes_to_analyze: LINKED_SET[CLASS_C]
164
165 system_wide_check: BOOLEAN
166
167 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date ID Revision

  ViewVC Help
Powered by ViewVC 1.1.23