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

Contents of /branches/eth/eve/Src/framework/code_analysis/rules/ca_cq_separation_rule.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 93426 - (show annotations)
Tue Nov 19 08:45:14 2013 UTC (6 years ago) by zurfluhs
File size: 3248 byte(s)
Code Analysis: GUI:

- analysis options in class indexing clauses
  - rules that ignore class
  - library / nonlibrary classes
1 note
2 description: "Summary description for {CA_CQ_SEPARATION_RULE}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 CA_CQ_SEPARATION_RULE
9
10 inherit
11 CA_STANDARD_RULE
12 redefine
13 id
14 end
15
16 create
17 make
18
19 feature {NONE} -- Initialization
20
21 make
22 do
23 is_enabled := True
24 create {CA_WARNING} severity
25 create violations.make
26 end
27
28 feature {NONE} -- Activation
29
30 register_actions (a_checker: CA_ALL_RULES_CHECKER)
31 do
32 a_checker.add_feature_pre_action (agent pre_process_feature)
33 a_checker.add_feature_post_action (agent post_process_feature)
34
35 a_checker.add_assign_pre_action (agent process_assign)
36 a_checker.add_creation_pre_action (agent process_creation)
37 a_checker.add_instruction_call_pre_action (agent process_instruction_call)
38 end
39
40 feature {NONE} -- AST Visits
41
42 pre_process_feature (a_feature: FEATURE_AS)
43 do
44 is_function := a_feature.is_function
45 rule_violated := False
46 end
47
48 post_process_feature (a_feature: FEATURE_AS)
49 local
50 l_violation: CA_RULE_VIOLATION
51 do
52 if rule_violated then
53 create l_violation.make_with_rule (Current)
54 l_violation.set_location (a_feature.start_location)
55 l_violation.long_description_info.extend (a_feature.feature_name.name_32)
56 violations.extend (l_violation)
57 end
58 end
59
60 is_function, rule_violated: BOOLEAN
61
62 process_assign (a_assign: ASSIGN_AS)
63 do
64 -- Skip the checks if we are not within a function.
65 if is_function then
66 if attached {ACCESS_ID_AS} a_assign.target as l_access_id then
67 if checking_class.feature_with_id (l_access_id.feature_name) /= Void then
68 -- We have an assignment to an attribute.
69 rule_violated := True
70 end
71 end
72 end
73 end
74
75 process_creation (a_creation: CREATION_AS)
76 do
77 -- Skip the checks if we are not within a function.
78 if is_function then
79 if attached {ACCESS_ID_AS} a_creation.target as l_access_id then
80 if checking_class.feature_with_id (l_access_id.feature_name) /= Void then
81 -- We have a creation of an attribute.
82 rule_violated := True
83 end
84 end
85 end
86 end
87
88 process_instruction_call (a_call: INSTR_CALL_AS)
89 do
90 -- Skip the checks if we are not within a function.
91 if is_function then
92 if attached {ACCESS_ID_AS} a_call.call as l_access_id then
93 if attached checking_class.feature_with_id (l_access_id.feature_name) as l_feat then
94 if l_feat.is_procedure then
95 -- There is a procedure call within this function.
96 rule_violated := True
97 end
98 end
99 end
100 end
101 end
102
103 feature -- Properties
104
105 title: STRING
106 do
107 Result := ca_names.cq_separation_title
108 end
109
110 id: STRING = "CA004T"
111 -- "T" stands for 'under test'.
112
113 description: STRING
114 do
115 Result := "---"
116 end
117
118 options: LINKED_LIST[CA_RULE_OPTION[ANY]]
119 once
120 create Result.make
121 end
122
123 is_system_wide: BOOLEAN = False
124
125 format_violation_description (a_violation: CA_RULE_VIOLATION; a_formatter: TEXT_FORMATTER)
126 do
127 a_formatter.add_string (ca_messages.cq_separation_violation_1)
128 if attached {STRING_32} a_violation.long_description_info.first as l_feature_name then
129 a_formatter.add_feature_name (l_feature_name, a_violation.affected_class)
130 end
131 a_formatter.add_string (ca_messages.cq_separation_violation_2)
132 end
133 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23