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

Contents of /branches/eth/eve/Src/framework/code_analysis/rules/ca_unused_argument_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: 3806 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_UNUSED_ARGUMENT_RULE}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 CA_UNUSED_ARGUMENT_RULE
9 inherit
10 CA_STANDARD_RULE
11 redefine
12 id
13 end
14
15 create
16 make
17
18 feature {NONE} -- Initialization
19 make
20 do
21 -- set the default parameters (subject to be changed by user)
22 is_enabled := True
23 create {CA_WARNING} severity
24 create violations.make
25 end
26
27 feature {NONE} -- Activation
28
29 register_actions (a_checker: CA_ALL_RULES_CHECKER)
30 do
31 a_checker.add_feature_pre_action (agent process_feature)
32 a_checker.add_body_pre_action (agent process_body)
33 a_checker.add_body_post_action (agent post_process_body)
34 a_checker.add_access_id_pre_action (agent process_access_id)
35 end
36
37 feature -- Properties
38
39 title: STRING
40 do
41 Result := ca_names.unused_argument_title
42 end
43
44 id: STRING = "CA002T"
45 -- "T" stands for 'under test'.
46
47 description: STRING
48 do
49 Result := ca_names.unused_argument_description
50 end
51
52 options: LINKED_LIST[CA_RULE_OPTION[ANY]]
53 once
54 create Result.make
55 end
56
57
58 is_system_wide: BOOLEAN
59 once
60 Result := False
61 end
62
63 format_violation_description (a_violation: CA_RULE_VIOLATION; a_formatter: TEXT_FORMATTER)
64 local
65 j: INTEGER
66 do
67 a_formatter.add_string (ca_messages.unused_argument_violation_1)
68 from
69 j := 2
70 until
71 j > a_violation.long_description_info.count
72 loop
73 if j > 2 then a_formatter.add_string (", ") end
74 a_formatter.add_char ('%'')
75 if attached {STRING} a_violation.long_description_info.at (j) as l_arg then
76 a_formatter.add_string (l_arg)
77 end
78 a_formatter.add_char('%'')
79 j := j + 1
80 end
81 a_formatter.add_string (ca_messages.unused_argument_violation_2)
82 if attached {FEATURE_AS} a_violation.long_description_info.first as l_feature then
83 a_formatter.add_feature_name (l_feature.feature_name.name_32, a_violation.affected_class)
84 end
85 a_formatter.add_string (ca_messages.unused_argument_violation_3)
86 end
87
88 feature {NONE} -- Rule Checking
89
90 process_feature (a_feature_as: FEATURE_AS)
91 do
92 current_feature := a_feature_as
93 end
94
95 process_body (a_body_as: BODY_AS)
96 local
97 j: INTEGER
98 do
99 has_arguments := (a_body_as.arguments /= Void)
100 if attached a_body_as.as_routine as l_rout then
101 if has_arguments and (not l_rout.is_external) then
102 routine_body := a_body_as
103 create arg_names.make (0)
104 create args_used.make (0)
105 n_arguments := 0
106 across a_body_as.arguments as l_args loop
107 from
108 j := 1
109 until
110 j > l_args.item.id_list.count
111 loop
112 arg_names.extend (l_args.item.item_name (j))
113 args_used.extend (False)
114 n_arguments := n_arguments + 1
115 j := j + 1
116 end
117 end
118 end
119 end
120 end
121
122 post_process_body (a_body: BODY_AS)
123 local
124 l_violation: CA_RULE_VIOLATION
125 j: INTEGER
126 do
127 if has_arguments and then args_used.has (False) then
128 create l_violation.make_with_rule (Current)
129 l_violation.set_location (routine_body.start_location)
130 l_violation.long_description_info.extend (current_feature)
131 from
132 j := 1
133 until
134 j > n_arguments
135 loop
136 if args_used.at (j) = False then
137 l_violation.long_description_info.extend (arg_names.at (j))
138 end
139 j := j + 1
140 end
141 violations.extend (l_violation)
142 end
143 end
144
145 process_access_id (a_aid: ACCESS_ID_AS)
146 local
147 j: INTEGER
148 do
149 from
150 j := 1
151 until
152 j > n_arguments
153 loop
154 if args_used.at (j) = False then
155 if arg_names.at (j).is_equal (a_aid.feature_name.name_8) then
156 args_used.put_i_th (True, j)
157 end
158 end
159 j := j + 1
160 end
161 end
162
163 has_arguments: BOOLEAN
164 current_feature: FEATURE_AS
165 routine_body: BODY_AS
166 n_arguments: INTEGER
167 arg_names: ARRAYED_LIST[STRING]
168 args_used: ARRAYED_LIST[BOOLEAN]
169
170 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23