Skip to content

Commit

Permalink
Merge branch 'main' into ISSUE_4
Browse files Browse the repository at this point in the history
  • Loading branch information
dedece35 authored Dec 15, 2023
2 parents 170e25f + 2e86afb commit 16cae3e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#5](https://github.com/green-code-initiative/ecoCode-python/pull/5) Upgrade licence system and licence headers of Java files
- [#6](https://github.com/green-code-initiative/ecoCode-python/pull/6) Adding EC35 rule : EC35 rule replaces EC34 with a specific use case ("file not found" sepcific)
- [#7](https://github.com/green-code-initiative/ecoCode-python/issues/7) Add build number to manifest
- Update ecocode-rules-specifications to 0.0.9
- [#123](https://github.com/green-code-initiative/ecoCode/issues/123) Imprive unit tests for EC7 rule
- Update ecocode-rules-specifications to 0.0.10

### Deleted

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<mockito.version>5.3.1</mockito.version>

<!-- temporary version waiting for real automatic release in ecocode repository -->
<ecocode-rules-specifications.version>0.0.9</ecocode-rules-specifications.version>
<ecocode-rules-specifications.version>0.0.10</ecocode-rules-specifications.version>

<sonar-analyzer-commons.version>2.5.0.1358</sonar-analyzer-commons.version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class AvoidGettersAndSettersTest {

@Test
public void test() {
PythonCheckVerifier.verify("src/test/resources/checks/avoidGettersAndSetters.py", new AvoidGettersAndSetters());
PythonCheckVerifier.verifyNoIssue("src/test/resources/checks/avoidGettersAndSettersCompliant.py", new AvoidGettersAndSetters());
PythonCheckVerifier.verify("src/test/resources/checks/avoidGettersAndSettersNonCompliant.py", new AvoidGettersAndSetters());
}
}
20 changes: 20 additions & 0 deletions src/test/resources/checks/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 16cae3e

Please sign in to comment.