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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 94865 - (show annotations)
Wed Apr 16 16:18:27 2014 UTC (5 years, 6 months ago) by apaolo
File size: 1989 byte(s)
Improved rules about naming conventions: they are now able to actually check the identifiers' case.
1 note
2 description: "[
3 RULE #64: Feature naming convention violated
4
5 Feature names should respect the Eiffel naming convention for features
6 (all lowercase, no trailing or two consecutive underscores).
7 ]"
8 author: "Paolo Antonucci"
9 date: "$Date$"
10 revision: "$Revision$"
11
12 class
13 CA_FEATURE_NAMING_CONVENTION_RULE
14
15 inherit
16
17 CA_STANDARD_RULE
18
19 create
20 make
21
22 feature {NONE} -- Initialization
23
24 make
25 -- Initialization for `Current'.
26 do
27 make_with_defaults
28 end
29
30 feature {NONE} -- Activation
31
32 register_actions (a_checker: attached CA_ALL_RULES_CHECKER)
33 do
34 a_checker.add_feature_pre_action (agent process_feature)
35 end
36
37 feature {NONE} -- Rule checking
38
39 process_feature (a_feature_as: attached FEATURE_AS)
40 local
41 l_name: STRING
42 l_viol: CA_RULE_VIOLATION
43 do
44 l_name := a_feature_as.feature_name.text_32 (current_context.matchlist)
45 if not is_valid_feature_name (l_name) then
46 create l_viol.make_with_rule (Current)
47 l_viol.set_location (a_feature_as.start_location)
48 l_viol.long_description_info.extend (l_name)
49 violations.extend (l_viol)
50 end
51 end
52
53 is_valid_feature_name (a_name: attached STRING): BOOLEAN
54 do
55 Result := not a_name.ends_with ("_") and not a_name.has_substring ("__") and (a_name.as_lower ~ a_name)
56 end
57
58 feature -- Properties
59
60 title: STRING_32
61 do
62 Result := ca_names.feature_naming_convention_title
63 end
64
65 id: STRING_32 = "CA064"
66
67 description: STRING_32
68 do
69 Result := ca_names.feature_naming_convention_description
70 end
71
72 format_violation_description (a_violation: attached CA_RULE_VIOLATION; a_formatter: attached TEXT_FORMATTER)
73 do
74 a_formatter.add (ca_messages.feature_naming_convention_violation_1)
75 check attached {STRING} a_violation.long_description_info.first as feature_name then
76 a_formatter.add (feature_name)
77 end
78 a_formatter.add (ca_messages.feature_naming_convention_violation_2)
79 end
80
81 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23