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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 93427 - (show annotations)
Tue Nov 19 10:39:06 2013 UTC (6 years ago) by zurfluhs
File size: 2314 byte(s)
Code Analyzer: added rule 'unneeded object test local'.
1 note
2 description: "Summary description for {CA_UNNEEDED_OBJECT_TEST_RULE}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 CA_UNNEEDED_OBJECT_TEST_RULE
9
10 inherit
11 CA_STANDARD_RULE
12 redefine id end
13
14 create
15 make
16
17 feature {NONE} -- Initialization
18
19 make
20 do
21 is_enabled := True
22 create {CA_SUGGESTION} severity
23 create violations.make
24 end
25
26 feature {NONE} -- Activation
27
28 register_actions (a_checker: CA_ALL_RULES_CHECKER)
29 do
30 a_checker.add_object_test_pre_action (agent process_object_test)
31 end
32
33 feature -- Properties
34
35 title: STRING
36 do
37 Result := ca_names.unneeded_object_test_title
38 end
39
40 id: STRING = "CA005T"
41 -- "T" stands for 'under test'.
42
43 description: STRING
44 do
45 Result := ca_names.unneeded_object_test_description
46 end
47
48 options: LINKED_LIST[CA_RULE_OPTION[ANY]]
49 once
50 create Result.make
51 end
52
53 is_system_wide: BOOLEAN = False
54
55 format_violation_description (a_violation: CA_RULE_VIOLATION; a_formatter: TEXT_FORMATTER)
56
57 do
58 a_formatter.add_char ('%'')
59 if attached {STRING_32} a_violation.long_description_info.first as l_name then
60 a_formatter.add_string (l_name)
61 end
62 a_formatter.add_string (ca_messages.unneeded_object_test_violation_1)
63 if attached {STRING_32} a_violation.long_description_info.at (2) as l_name then
64 a_formatter.add_string (l_name)
65 end
66 a_formatter.add_string ("'.")
67 end
68
69 feature {NONE} -- AST Visits
70
71 process_object_test (a_ot: OBJECT_TEST_AS)
72 local
73 l_violation: CA_RULE_VIOLATION
74 do
75 -- The expression to be tested must be a simple call.
76 if attached {EXPR_CALL_AS} a_ot.expression as l_call then
77 if attached {ACCESS_ID_AS} l_call.call as l_access then
78 -- Testing if an object test local is used.
79 if attached a_ot.name as l_ot_local then
80 -- Now we have to check whether the tested expression is a local,
81 -- an argument, or an object test local.
82 if l_access.is_local or l_access.is_argument or l_access.is_object_test_local then
83 create l_violation.make_with_rule (Current)
84 l_violation.set_location (a_ot.start_location)
85 l_violation.long_description_info.extend (l_access.access_name_32)
86 l_violation.long_description_info.extend (l_ot_local.name_32)
87 violations.extend (l_violation)
88 end
89 end
90 end
91 end
92 end
93
94 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23