Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breizh camp2023 #5

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions src/AvoidListComprehensionInIterations.py

This file was deleted.

39 changes: 39 additions & 0 deletions src/starWarsLegion_trainings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
##########
# NON COMPLIANT for "list comprehension"
##########

def non_compliant_training_1():
weapons_list = ['green_light_saber', 'blue_light_saber', 'red_light_saber']
for current_weapon in [weapon for weapon in weapons_list]: # Noncompliant {{Use generator comprehension instead of list comprehension in for loop declaration}}
print(current_weapon)

def non_compliant_training_2():
for current_weapon in [weapon_number for weapon_number in range(1000)]: # Noncompliant {{Use generator comprehension instead of list comprehension in for loop declaration}}
print(current_weapon)


##########
# COMPLIANT for "list comprehension"
##########

def compliant_training_1():
weapons_list = ['green_light_saber', 'blue_light_saber', 'red_light_saber']
for current_weapon in weapons_list:
print(current_weapon)

def compliant_training_2():
weapons_number_list = range(10)
for current_weapon in weapons_number_list:
print(current_weapon)

def compliant_training_3():
for current_weapon in ('saber_green', 'saber_blue', 'saber_red'):
print(current_weapon)

def compliant_training_4():
for current_weapon in ['saber_purple', 'saber_pink', 'saber_white']:
print(current_weapon)

def compliant_training_5():
for current_weapon in (weapon_number for weapon_number in range(1000)):
print(current_weapon)