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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 94873 - (show annotations)
Wed Apr 16 17:40:07 2014 UTC (5 years, 10 months ago) by apaolo
File size: 2095 byte(s)
Implemented new "Inspect instruction has no 'when' branch" and "Explicit redundant inheritance" Inspector Eiffel rules.
1 note
2 description: "[
3 RULE #59: Empty rescue clause
4
5 An empty rescue clause should be avoided and leads to undesirable program behaviour.
6 ]"
7 author: "Paolo Antonucci"
8 date: "$Date$"
9 revision: "$Revision$"
10
11 class
12 CA_EMPTY_RESCUE_CLAUSE_RULE
13
14 inherit
15
16 CA_STANDARD_RULE
17
18 create
19 make
20
21 feature {NONE} -- Initialization
22
23 make
24 -- Initialization for `Current'.
25 do
26 make_with_defaults
27 end
28
29 feature {NONE} -- Activation
30
31 register_actions (a_checker: attached CA_ALL_RULES_CHECKER)
32 do
33 a_checker.add_feature_pre_action (agent process_feature)
34 end
35
36 feature {NONE} -- Rule checking
37
38 process_feature (a_feature_as: FEATURE_AS)
39 local
40 l_rescue_keyword: KEYWORD_AS
41 l_viol: CA_RULE_VIOLATION
42 do
43 if attached {ROUTINE_AS} a_feature_as.body.content as routine_as then
44 -- routine_as.has_rescue is not very helpful, as it only tells us
45 -- if the routine has a *non empty* rescue clause.
46 l_rescue_keyword := routine_as.rescue_keyword (current_context.matchlist)
47 if attached l_rescue_keyword and (routine_as.rescue_clause = Void or else routine_as.rescue_clause.is_empty) then
48 create l_viol.make_with_rule (Current)
49 l_viol.set_location (l_rescue_keyword.start_location)
50 l_viol.long_description_info.extend (a_feature_as.feature_name.name_8)
51 violations.extend (l_viol)
52 end
53 end
54 end
55
56 feature -- Properties
57
58 title: STRING_32
59 do
60 Result := ca_names.empty_rescue_clause_title
61 end
62
63 id: STRING_32 = "CA059"
64 -- <Precursor>
65
66 description: STRING_32
67 do
68 Result := ca_names.empty_rescue_clause_description
69 end
70
71 format_violation_description (a_violation: attached CA_RULE_VIOLATION; a_formatter: attached TEXT_FORMATTER)
72 do
73 a_formatter.add (ca_messages.empty_rescue_clause_violation_1)
74 check attached {STRING} a_violation.long_description_info.first as feature_name then
75 a_formatter.add_feature_name (feature_name, a_violation.affected_class)
76 end
77 a_formatter.add (ca_messages.empty_rescue_clause_violation_2)
78 end
79
80 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23