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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 94865 - (show annotations)
Wed Apr 16 16:18:27 2014 UTC (5 years, 5 months ago) by apaolo
File size: 2048 byte(s)
Improved rules about naming conventions: they are now able to actually check the identifiers' case.
1 note
2 description: "[
3 RULE #63: Class naming convention violated
4
5 Class names should respect the Eiffel naming convention for classes
6 (all uppercase, no trailing or two consecutive underscores).
7 ]"
8 author: "Paolo Antonucci"
9 date: "$Date$"
10 revision: "$Revision$"
11
12 class
13 CA_CLASS_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_class_pre_action (agent process_class)
35 end
36
37 feature {NONE} -- Rule checking
38
39 process_class (a_class_as: attached CLASS_AS)
40 local
41 l_name: STRING
42 l_viol: CA_RULE_VIOLATION
43 do
44 -- Retrieving the original text is the only way for checking the case (otherwise it's always lowercased).
45 l_name := a_class_as.class_name.text_32 (current_context.matchlist)
46 if not is_valid_class_name (l_name) then
47 create l_viol.make_with_rule (Current)
48 l_viol.set_location (a_class_as.class_name.start_location)
49 violations.extend (l_viol)
50 end
51 end
52
53 is_valid_class_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_upper ~ a_name)
56 end
57
58 feature -- Properties
59
60 title: STRING_32
61 do
62 Result := ca_names.class_naming_convention_title
63 end
64
65 id: STRING_32 = "CA063"
66 -- <Precursor>
67
68 description: STRING_32
69 do
70 Result := ca_names.class_naming_convention_description
71 end
72
73 format_violation_description (a_violation: attached CA_RULE_VIOLATION; a_formatter: attached TEXT_FORMATTER)
74 do
75 a_formatter.add (ca_messages.class_naming_convention_violation_1)
76 check attached a_violation.affected_class as affected_class then
77 a_formatter.add_class (affected_class.original_class)
78 end
79 a_formatter.add (ca_messages.class_naming_convention_violation_2)
80 end
81
82 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23