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

Contents of /branches/eth/eve/Src/framework/code_analysis/rules/ca_self_assignment_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: 1966 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_SELF_ASSIGNMENT_RULE}."
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 CA_SELF_ASSIGNMENT_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 make
21 do
22 -- set the default parameters (subject to be changed by user)
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_assign_pre_action (agent pre_assign)
33 end
34
35 feature -- Properties
36
37 title: STRING
38 do
39 Result := ca_names.self_assignment_title
40 end
41
42 id: STRING = "CA001T"
43 -- "T" stands for 'under test'.
44
45 description: STRING
46 do
47 Result := ca_names.self_assignment_description
48 end
49
50 options: LINKED_LIST[CA_RULE_OPTION[ANY]]
51 once
52 create Result.make
53 end
54
55 is_system_wide: BOOLEAN
56 once
57 Result := False
58 end
59
60 format_violation_description (a_violation: CA_RULE_VIOLATION; a_formatter: TEXT_FORMATTER)
61 do
62 a_formatter.add_string (ca_messages.self_assignment_violation_1)
63 if attached {STRING_32} a_violation.long_description_info.first as l_name then
64 a_formatter.add_string (l_name)
65 end
66 a_formatter.add_string (ca_messages.self_assignment_violation_2)
67 end
68
69 feature {NONE} -- Checking the rule
70 pre_assign (a_assign_as: ASSIGN_AS)
71 local
72 l_violation: CA_RULE_VIOLATION
73 do
74 if attached {EXPR_CALL_AS} a_assign_as.source as l_source then
75 if attached {ACCESS_ID_AS} l_source.call as l_src_access_id then
76 if attached {ACCESS_ID_AS} a_assign_as.target as l_tar
77 and then l_tar.feature_name.is_equal (l_src_access_id.feature_name) then
78 create l_violation.make_with_rule (Current)
79 l_violation.set_location (a_assign_as.start_location)
80 l_violation.long_description_info.extend (l_src_access_id.feature_name.name_32)
81 violations.extend (l_violation)
82 end
83 end
84 end
85 end
86
87 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23