Skip to content

Commit

Permalink
Merge pull request #8 from green-code-initiative/ISSUE_123_ecocode
Browse files Browse the repository at this point in the history
[ISSUE 123] complete real tests for EC7 rule
  • Loading branch information
dedece35 authored Dec 15, 2023
2 parents fe1531d + 6721d85 commit 8bf211c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/avoidGettersAndSettersCompliant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from datetime import date

class Client():

def __init__(self, age, weight):
self.age = age
self.weight = weight

def get_age_in_five_years(self):
a = Client()
return a.age

def is_major(self):
return self.age >= 18

client = Client(25)
client.age
client.age = 25
client.weight
client.weight(5)
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ def is_major(self):

def get_weight(self): # Noncompliant {{Avoid creating getter and setter methods in classes}}
return self.weight

client = Client(25)
client.get_age()
client.set_age(25)
client.get_weight()
client.set_weight(5)

0 comments on commit 8bf211c

Please sign in to comment.