Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d4f08c4b4a | |||
| c136e1a30a | |||
| 96c5d9043d | |||
| dc1e6ff8fc | |||
| ad8bdb3774 | |||
| 281ff30b66 | |||
| cd45b86ea1 | |||
| 2374f7c55d | |||
| 620b36b382 | |||
| f7fc04c833 | |||
| e5241d25fa |
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* R5.A.04 - Qualité Algorithmique
|
||||
* TD Complexité cyclomatique - Partie Java
|
||||
*
|
||||
|
||||
+259
@@ -0,0 +1,259 @@
|
||||
Ugo Faye
|
||||
Cléo Camille
|
||||
Mathis Leclere
|
||||
|
||||
# Compte rendu – TD Complexité cyclomatique (R5.A.04)
|
||||
|
||||
Formules utilisées :
|
||||
- avec le graphe : **M = E − N + 2P** (E arêtes, N sommets, P = 1)
|
||||
- en comptant : **M = décisions + 1**
|
||||
|
||||
Classement selon la grille du cours : 1–10 simple, 11–20 modéré, 21–50 complexe, > 50 très risqué.
|
||||
|
||||
---
|
||||
|
||||
# Partie C – `exercices.c`
|
||||
|
||||
## __C1__ – `carre`
|
||||
- complexite = 0 decisions + 1 = 1
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __C2__ – `moyenne`
|
||||
|
||||

|
||||
|
||||
- complexite = 9 aretes − 8 sommets + 2 = 3
|
||||
- complexite = 2 decisions + 1 = 3
|
||||
|
||||
> **Cas particuliers:**
|
||||
- ternaire `n > 0 ? ... : 0` : compte pour 1
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __C3__ – `est_bissextile`
|
||||
- complexite = 2 decisions + 1 = 3
|
||||
|
||||
> **Cas particuliers:**
|
||||
- `&&` et `||` sans `if` : 1 decision chacun (evaluation paresseuse)
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __C4__ – `nom_jour`
|
||||
|
||||

|
||||
|
||||
- complexite = 16 aretes − 10 sommets + 2 = 8
|
||||
- complexite = 7 decisions + 1 = 8
|
||||
|
||||
> **Cas particuliers:**
|
||||
- 7 `case` : 1 decision chacun
|
||||
- `default` : ne compte pas
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __C5__ – `compter_mots`
|
||||
- complexite = 7 decisions + 1 = 8
|
||||
|
||||
> **Cas particuliers:**
|
||||
- `while` : 1
|
||||
- `separateur = (... || ... || ... || ... || ...)` : 4 `||` sans `if`
|
||||
- `if` + `else if` : 2
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __C6__ – `date_valide`
|
||||
- complexite = 10 decisions + 1 = 11
|
||||
|
||||
> **Cas particuliers:**
|
||||
- 1er `if` + 3 `||` : 4
|
||||
- `if (mois == 2)` + `if (est_bissextile)` : 2
|
||||
- `else if` + 3 `||` : 4
|
||||
- l'appel a `est_bissextile` ne compte pas (M est calcule par fonction)
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Modéré
|
||||
|
||||
---
|
||||
|
||||
# Partie Java – `Bibliotheque.java`
|
||||
|
||||
## __J1__ – `nombreDeLivres`
|
||||
- complexite = 0 decisions + 1 = 1
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __J2__ – `estDisponible`
|
||||
|
||||

|
||||
|
||||
- complexite = 5 aretes − 4 sommets + 2 = 3
|
||||
- complexite = 2 decisions + 1 = 3
|
||||
|
||||
> **Cas particuliers:**
|
||||
- 2 `&&` sans `if` : 1 decision chacun
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __J3__ – `peutEmprunter`
|
||||
- complexite = 8 decisions + 1 = 9
|
||||
|
||||
> **Cas particuliers:**
|
||||
- 4 `if` + 2 `else if`
|
||||
- ternaire `a.etudiant ? 8 : 5` : +1
|
||||
- `l.reserve && !a.etudiant` : +1
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __J4__ – `calculerPenalite`
|
||||
- complexite = 8 decisions + 1 = 9
|
||||
|
||||
> **Cas particuliers:**
|
||||
- 4 `if` + 1 `else if` + 1 `for`
|
||||
- `joursRetard <= 0 || nbLivres <= 0` : +1
|
||||
- ternaire `penalite > 50 ? 50 : penalite` : +1
|
||||
- `else` : ne compte pas
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __J5__ – `rechercher`
|
||||
- complexite = 10 decisions + 1 = 11
|
||||
|
||||
> **Cas particuliers:**
|
||||
- 1 `for` + 5 `if`
|
||||
- `genre != null && ...` : +1
|
||||
- `disponiblesSeulement && ...` : +1
|
||||
- `motCle == null || ...` : +1
|
||||
- `titre.contains(m) || auteur.contains(m)` : +1
|
||||
- `continue` : ne compte pas
|
||||
- l'appel a `estDisponible` ne compte pas
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Modéré
|
||||
|
||||
## __J6__ – `importer`
|
||||
|
||||

|
||||
|
||||
- complexite = 21 aretes − 15 sommets + 2 = 8
|
||||
- complexite = 7 decisions + 1 = 8
|
||||
|
||||
> **Cas particuliers:**
|
||||
- 2 : `for`
|
||||
- 3/4 : `if` + `||`
|
||||
- 7 : `if`
|
||||
- 10/11 : `if` + `&&`
|
||||
- 13 : `catch`
|
||||
- `continue` : ne compte pas
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
---
|
||||
|
||||
# Partie Python – `exercices.py`
|
||||
|
||||
## __P1__ – `celsius_vers_fahrenheit`
|
||||
- complexite = 0 decisions + 1 = 1
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __P2__ – `signe`
|
||||
|
||||

|
||||
|
||||
- complexite = 7 aretes − 6 sommets + 2 = 3
|
||||
- complexite = 2 decisions + 1 = 3
|
||||
|
||||
> **Cas particuliers:**
|
||||
- `if` + `elif`
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __P3__ – `notes_valides`
|
||||
|
||||

|
||||
|
||||
- complexite = 6 aretes − 5 sommets + 2 = 3
|
||||
- complexite = 2 decisions + 1 = 3
|
||||
|
||||
> **Cas particuliers:**
|
||||
- comprehension de liste = 1 `for` + 1 `if`
|
||||
- `0 <= n <= 20` : comparaison chainee comptee comme 1 seule condition
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __P4__ – `mention`
|
||||
- complexite = 2 decisions + 1 = 3
|
||||
|
||||
> **Cas particuliers:**
|
||||
- le dictionnaire remplace une cascade de `if/elif` (qui aurait donne M = 5)
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Simple
|
||||
|
||||
## __P5__ – `analyser_mot_de_passe`
|
||||
- complexite = 15 decisions + 1 = 16
|
||||
|
||||
> **Cas particuliers:**
|
||||
- 2 `for`, 8 `if`, 2 `elif`
|
||||
- `majuscule and minuscule` : +1
|
||||
- `login and login.lower() in ...` : +1
|
||||
- ternaire `"moyen" if ... else "faible"` : +1
|
||||
- `else` et `break` : ne comptent pas
|
||||
|
||||
> **Classement:**
|
||||
|
||||
Modéré
|
||||
|
||||
---
|
||||
|
||||
# Récapitulatif
|
||||
|
||||
| Fonction | M | Classement |
|
||||
|---|---|---|
|
||||
| C1 `carre` | 1 | Simple |
|
||||
| C2 `moyenne` | 3 | Simple |
|
||||
| C3 `est_bissextile` | 3 | Simple |
|
||||
| C4 `nom_jour` | 8 | Simple |
|
||||
| C5 `compter_mots` | 8 | Simple |
|
||||
| C6 `date_valide` | 11 | Modéré |
|
||||
| J1 `nombreDeLivres` | 1 | Simple |
|
||||
| J2 `estDisponible` | 3 | Simple |
|
||||
| J3 `peutEmprunter` | 9 | Simple |
|
||||
| J4 `calculerPenalite` | 9 | Simple |
|
||||
| J5 `rechercher` | 11 | Modéré |
|
||||
| J6 `importer` | 8 | Simple |
|
||||
| P1 `celsius_vers_fahrenheit` | 1 | Simple |
|
||||
| P2 `signe` | 3 | Simple |
|
||||
| P3 `notes_valides` | 3 | Simple |
|
||||
| P4 `mention` | 3 | Simple |
|
||||
| P5 `analyser_mot_de_passe` | 16 | Modéré |
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 92 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 339 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 MiB |
+17
-3
@@ -40,6 +40,16 @@ def analyser_mot_de_passe(mdp, login=None):
|
||||
if len(mdp) < 12:
|
||||
problemes.append("trop court")
|
||||
majuscule = minuscule = chiffre = special = False
|
||||
kindOfLetter(mdp)
|
||||
verifyCharMix(problemes)
|
||||
verifyPswdSafety(problemes)
|
||||
if not problemes:
|
||||
return "fort", []
|
||||
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
|
||||
|
||||
|
||||
|
||||
def kindOfLetter(mdp):
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
majuscule = True
|
||||
@@ -49,21 +59,25 @@ def analyser_mot_de_passe(mdp, login=None):
|
||||
chiffre = True
|
||||
else:
|
||||
special = True
|
||||
return [majuscule, minuscule, chiffre, special]
|
||||
|
||||
def verifyCharMix(problemes):
|
||||
if not (majuscule and minuscule):
|
||||
problemes.append("mélanger majuscules et minuscules")
|
||||
if not chiffre:
|
||||
problemes.append("ajouter un chiffre")
|
||||
if not special:
|
||||
problemes.append("ajouter un caractère spécial")
|
||||
return problemes
|
||||
|
||||
def verifyPswdSafety(problemes):
|
||||
if login and login.lower() in mdp.lower():
|
||||
problemes.append("ne pas contenir le login")
|
||||
for i in range(len(mdp) - 2):
|
||||
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
|
||||
problemes.append("éviter 3 caractères identiques")
|
||||
break
|
||||
if not problemes:
|
||||
return "fort", []
|
||||
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
|
||||
return problemes
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user