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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 93177 - (hide 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 zurfluhs 93168 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 zurfluhs 93173
27     create classes_to_analyze.make
28     create rule_violations.make (100)
29 zurfluhs 93168 end
30    
31 zurfluhs 93173 feature -- Analysis interface
32 zurfluhs 93168
33 zurfluhs 93173 analyze
34 zurfluhs 93168 local
35 zurfluhs 93173 l_rules_checker: CA_ALL_RULES_CHECKER
36 zurfluhs 93168 do
37 zurfluhs 93173 create l_rules_checker.make
38 zurfluhs 93168 across rules as l_rules loop
39     if l_rules.item.is_enabled then -- important: only add enabled rules
40 zurfluhs 93174 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 zurfluhs 93168 end
45     end
46    
47 zurfluhs 93173 across classes_to_analyze as l_classes loop
48 zurfluhs 93177
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 zurfluhs 93173 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 zurfluhs 93177 end
58 zurfluhs 93173
59 zurfluhs 93177 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 zurfluhs 93173 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 zurfluhs 93168 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 zurfluhs 93173 add_cluster (l_cluster)
90 zurfluhs 93168 end
91     l_groups.forth
92     end
93 zurfluhs 93174
94     system_wide_check := True
95 zurfluhs 93168 end
96    
97 zurfluhs 93173 add_cluster (a_cluster: CLUSTER_I)
98 zurfluhs 93168 local
99     l_conf_class: CONF_CLASS
100     l_class_i: CLASS_I
101     do
102 zurfluhs 93174 system_wide_check := False
103    
104 zurfluhs 93168 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 zurfluhs 93173 add_class (l_class_i)
112 zurfluhs 93168 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 zurfluhs 93173 add_cluster (a_cluster.sub_clusters.item_for_iteration)
121 zurfluhs 93168 a_cluster.sub_clusters.forth
122     end
123     end
124     end
125    
126 zurfluhs 93173 add_classes (a_classes: ITERABLE[CLASS_I])
127 zurfluhs 93168 do
128 zurfluhs 93174 system_wide_check := False
129    
130 zurfluhs 93173 across a_classes as l_classes loop
131     add_class (l_classes.item)
132     end
133 zurfluhs 93168 end
134    
135 zurfluhs 93173 add_class (a_class: CLASS_I)
136     local
137     l_class_c: CLASS_C
138 zurfluhs 93168 do
139 zurfluhs 93174 system_wide_check := False
140    
141 zurfluhs 93173 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 zurfluhs 93168 end
149     end
150    
151 zurfluhs 93173 feature -- Properties
152 zurfluhs 93168
153     analysis_successful: BOOLEAN
154    
155     rules: LINKED_LIST[CA_RULE]
156    
157 zurfluhs 93173 rule_violations: detachable HASH_TABLE[SORTED_TWO_WAY_LIST[CA_RULE_VIOLATION], CLASS_C]
158 zurfluhs 93168
159     feature {NONE} -- Implementation
160    
161     settings: CA_SETTINGS
162    
163 zurfluhs 93173 classes_to_analyze: LINKED_SET[CLASS_C]
164 zurfluhs 93168
165 zurfluhs 93174 system_wide_check: BOOLEAN
166    
167 zurfluhs 93168 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23