Adding code smell detection :
[nit.git] / tests / TestNitsmells / FeatureEnvy / featureenvy.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # A test program with a fake model to check model tools.
16 module featureenvy
17
18 import platform
19
20 class Starter
21 var attribute = 0
22 var attribute1 = 0
23 var attribute2 = 0
24 fun start do
25 self.attribute1 = 10
26 self.attribute = 2
27 end
28
29 fun ended do end
30 end
31
32 class FeatureEnvy
33 var testVariable = 0
34
35 fun feature_envy_method do
36 var starter = new Starter
37 testVariable = starter.attribute
38 if starter.attribute == self.testVariable then
39 starter.attribute = 10
40 end
41 end
42 end