Skip to content

Commit

Permalink
python/ellens-alien-game: 3rd iteration - pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed Jan 17, 2024
1 parent 6b21c38 commit 1704596
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 62 deletions.
Binary file modified python/ellens-alien-game/.coverage
Binary file not shown.
19 changes: 9 additions & 10 deletions python/ellens-alien-game/.coverage.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<coverage version="7.4.0" timestamp="1705469307718" lines-valid="23" lines-covered="23" line-rate="1" branches-valid="2" branches-covered="2" branch-rate="1" complexity="0">
<coverage version="7.4.0" timestamp="1705510267589" lines-valid="22" lines-covered="22" line-rate="1" branches-valid="2" branches-covered="2" branch-rate="1" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.4.0 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
Expand All @@ -20,20 +20,19 @@
<line number="30" hits="1"/>
<line number="31" hits="1"/>
<line number="33" hits="1"/>
<line number="34" hits="1"/>
<line number="36" hits="1"/>
<line number="35" hits="1"/>
<line number="37" hits="1"/>
<line number="39" hits="1"/>
<line number="40" hits="1"/>
<line number="41" hits="1"/>
<line number="43" hits="1"/>
<line number="44" hits="1"/>
<line number="47" hits="1"/>
<line number="48" hits="1"/>
<line number="51" hits="1"/>
<line number="53" hits="1"/>
<line number="55" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="56" hits="1"/>
<line number="46" hits="1"/>
<line number="50" hits="1"/>
<line number="52" hits="1"/>
<line number="55" hits="1"/>
<line number="57" hits="1"/>
<line number="59" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="60" hits="1"/>
</lines>
</class>
</classes>
Expand Down
6 changes: 5 additions & 1 deletion python/ellens-alien-game/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,24 @@ def __init__(self, x_coordinate: int, y_coordinate: int) -> None:
self.health: int = 3

def hit(self) -> None:
"""Hits do health damage."""
self.health -= 1

def is_alive(self) -> bool:
"""The alien is alive as long as it's health isn't zero."""
return self.health > 0

def teleport(self, x_coordinate: int, y_coordinate: int) -> None:
"""Teleports the alien to a new set of coordinates."""
self.x_coordinate = x_coordinate
self.y_coordinate = y_coordinate

def collision_detection(self, other: object) -> None:
pass
"""Aliens don't have car insurance so ignore collisions."""


def new_aliens_collection(positions: List[Tuple[int, int]]) -> List[Alien]:
"""Returns a new list of aliens"""
return [Alien(*position) for position in positions]


Expand Down
6 changes: 5 additions & 1 deletion python/ellens-alien-game/classes.py,cover
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,24 @@
> self.health: int = 3

> def hit(self) -> None:
> """Hits do health damage."""
> self.health -= 1

> def is_alive(self) -> bool:
> """The alien is alive as long as it's health isn't zero."""
> return self.health > 0

> def teleport(self, x_coordinate: int, y_coordinate: int) -> None:
> """Teleports the alien to a new set of coordinates."""
> self.x_coordinate = x_coordinate
> self.y_coordinate = y_coordinate

> def collision_detection(self, other: object) -> None:
> pass
> """Aliens don't have car insurance so ignore collisions."""


> def new_aliens_collection(positions: List[Tuple[int, int]]) -> List[Alien]:
> """Returns a new list of aliens"""
> return [Alien(*position) for position in positions]


Expand Down
96 changes: 46 additions & 50 deletions python/ellens-alien-game/run-tests-python.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,48 @@ Running automated test file(s):
===============================================================================

Running: pylint ./src
************* Module ellens_alien_game.classes
src/ellens_alien_game/classes.py:33:4: C0116: Missing function or method docstring (missing-function-docstring)
src/ellens_alien_game/classes.py:36:4: C0116: Missing function or method docstring (missing-function-docstring)
src/ellens_alien_game/classes.py:39:4: C0116: Missing function or method docstring (missing-function-docstring)
src/ellens_alien_game/classes.py:43:4: C0116: Missing function or method docstring (missing-function-docstring)
src/ellens_alien_game/classes.py:47:0: C0116: Missing function or method docstring (missing-function-docstring)

------------------------------------------------------------------
Your code has been rated at 7.83/10 (previous run: 8.33/10, -0.51)
-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 9.57/10, +0.43)


real 0m0.831s
user 0m0.726s
sys 0m0.109s
real 0m0.752s
user 0m0.683s
sys 0m0.071s

===============================================================================

Running: ruff check --ignore E501 ./src

real 0m0.087s
user 0m0.039s
sys 0m0.053s
real 0m0.071s
user 0m0.028s
sys 0m0.044s

===============================================================================

Running: pyright --stats ./src
Found 2 source files
pyright 1.1.347
0 errors, 0 warnings, 0 informations
Completed in 0.585sec
Completed in 0.553sec

Analysis stats
Total files parsed and bound: 20
Total files checked: 2

Timing stats
Find Source Files: 0sec
Read Source Files: 0sec
Read Source Files: 0.01sec
Tokenize: 0.04sec
Parse: 0.04sec
Resolve Imports: 0.06sec
Bind: 0.07sec
Resolve Imports: 0.04sec
Bind: 0.05sec
Check: 0.06sec
Detect Cycles: 0sec

real 0m1.487s
user 0m1.317s
sys 0m0.169s
real 0m1.332s
user 0m1.086s
sys 0m0.183s

===============================================================================

Expand All @@ -61,17 +55,19 @@ Running: bandit --verbose --recursive ./src
[main] INFO cli include tests: None
[main] INFO cli exclude tests: None
[main] INFO running on Python 3.12.1
Run started:2024-01-17 05:28:25.660640
Run started:2024-01-17 16:51:05.583963
Files in scope (2):
./src/ellens_alien_game/__init__.py (score: {SEVERITY: 0, CONFIDENCE: 0})
./src/ellens_alien_game/classes.py (score: {SEVERITY: 0, CONFIDENCE: 0})
Files excluded (0):
Files excluded (2):
./src/ellens_alien_game/__pycache__/__init__.cpython-312.pyc
./src/ellens_alien_game/__pycache__/classes.cpython-312.pyc

Test results:
No issues identified.

Code scanned:
Total lines of code: 38
Total lines of code: 42
Total lines skipped (#nosec): 0
Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Expand All @@ -88,17 +84,17 @@ Run metrics:
High: 0
Files skipped (0):

real 0m0.288s
user 0m0.214s
sys 0m0.076s
real 0m0.306s
user 0m0.225s
sys 0m0.083s

===============================================================================

Running: refurb ./src

real 0m1.142s
user 0m1.054s
sys 0m0.090s
real 0m1.093s
user 0m1.013s
sys 0m0.082s

===============================================================================

Expand All @@ -123,9 +119,9 @@ Test passed.
0 passed and 0 failed.
Test passed.

real 0m0.141s
user 0m0.076s
sys 0m0.067s
real 0m0.139s
user 0m0.088s
sys 0m0.053s


===============================================================================
Expand Down Expand Up @@ -157,43 +153,43 @@ test/classes_test.py::ClassesTest::test_new_aliens_collection PASSED [100%]
---------- coverage: platform linux, python 3.12.1-final-0 -----------
Name Stmts Miss Branch BrPart Cover Missing
--------------------------------------------------------
classes.py 23 0 2 0 100%
classes.py 22 0 2 0 100%
--------------------------------------------------------
TOTAL 23 0 2 0 100%
TOTAL 22 0 2 0 100%
Coverage XML written to file .coverage.xml


============================== 10 passed in 0.06s ==============================

real 0m0.844s
user 0m0.734s
sys 0m0.111s
real 0m0.841s
user 0m0.705s
sys 0m0.137s

===============================================================================

Running: coverage report --show-missing
Name Stmts Miss Branch BrPart Cover Missing
--------------------------------------------------------
classes.py 23 0 2 0 100%
classes.py 22 0 2 0 100%
--------------------------------------------------------
TOTAL 23 0 2 0 100%
TOTAL 22 0 2 0 100%

real 0m0.180s
user 0m0.115s
sys 0m0.068s
real 0m0.162s
user 0m0.100s
sys 0m0.064s

===============================================================================

coverage annotate

real 0m0.158s
user 0m0.103s
sys 0m0.057s
real 0m0.150s
user 0m0.102s
sys 0m0.049s

tail -n 10000 ./*,cover | grep -E -C 3 '^> def |^! '

> def new_aliens_collection(positions: List[Tuple[int, int]]) -> List[Alien]:
> return [Alien(*position) for position in positions]
> """Returns a new list of aliens"""
--
> from classes import new_aliens_collection
! except ImportError as err:
Expand All @@ -211,9 +207,9 @@ tail -n 10000 ./*,cover | grep -E -C 3 '^> def |^! '

Running: misspell ./src/ellens_alien_game/classes.py ./src/ellens_alien_game/__init__.py

real 0m0.023s
user 0m0.021s
sys 0m0.011s
real 0m0.021s
user 0m0.015s
sys 0m0.015s

===============================================================================

0 comments on commit 1704596

Please sign in to comment.