Fix : Code smells

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent 0936d63900
commit 4d98ec337e

@ -23,7 +23,7 @@ namespace Model
} }
} }
} }
private string name; private string name = default!;
[DataMember] [DataMember]
public string Description public string Description
@ -39,7 +39,7 @@ namespace Model
} }
} }
} }
private string description; private string description = default!;
[DataMember] [DataMember]
public int Year public int Year
@ -55,7 +55,7 @@ namespace Model
} }
} }
} }
private int year; private int year = default!;
[DataMember] [DataMember]
public string Cover public string Cover
@ -71,7 +71,7 @@ namespace Model
} }
} }
} }
private string cover; private string cover = default!;
[DataMember] [DataMember]
public ObservableCollection<string> Tags public ObservableCollection<string> Tags
@ -87,7 +87,7 @@ namespace Model
} }
} }
} }
private ObservableCollection<string> tags; private ObservableCollection<string> tags = default!;
[DataMember] [DataMember]
public List<Review> Reviews { get; private init; } public List<Review> Reviews { get; private init; }
@ -112,7 +112,7 @@ namespace Model
} }
} }
} }
private string lien; private string lien = default!;
public Game(string name, string description, int year, List<string> c_tags, string cover, string c_lien) public Game(string name, string description, int year, List<string> c_tags, string cover, string c_lien)
{ {

@ -27,10 +27,10 @@ namespace Model
.Where(game => game.Name.IndexOf(filterName, StringComparison.OrdinalIgnoreCase) >= 0 .Where(game => game.Name.IndexOf(filterName, StringComparison.OrdinalIgnoreCase) >= 0
); );
if (filterTag1 != null) retList = retList if (filterTag1 != null) retList = retList
.Where(game => game.Tags != null && game.Tags.Any(tag => tag != null && tag.IndexOf(filterTag1, StringComparison.OrdinalIgnoreCase) >= 0) .Where(game => game.Tags != null && game.Tags.Any(tag => tag != null && tag.Contains(filterTag1, StringComparison.OrdinalIgnoreCase))
); );
if (filterTag2 != null) retList = retList if (filterTag2 != null) retList = retList
.Where(game => game.Tags != null && game.Tags.Any(tag => tag != null && tag.IndexOf(filterTag2, StringComparison.OrdinalIgnoreCase) >= 0) .Where(game => game.Tags != null && game.Tags.Any(tag => tag != null && tag.Contains(filterTag2, StringComparison.OrdinalIgnoreCase))
); );
return retList; return retList;
} }

@ -10,6 +10,17 @@ namespace Model
[DataContract] [DataContract]
public sealed class User : INotifyPropertyChanged , IEquatable<User> public sealed class User : INotifyPropertyChanged , IEquatable<User>
{ {
[DataMember]
public string UserImage
{
get => userImage;
private set
{
if (!string.IsNullOrWhiteSpace(value)) userImage = value;
else userImage = "no_cover.png";
}
}
private string userImage = default!;
[DataMember] [DataMember]
public string? Username public string? Username
{ {
@ -24,11 +35,11 @@ namespace Model
} }
} }
} }
private string username; private string username=default!;
[DataMember] [DataMember]
public string Biographie public string Biographie
{ {
get => biographie ?? "Pas de biographie"; get => biographie;
private set private set
{ {
if (string.IsNullOrWhiteSpace(value)) biographie = "Pas de biographie"; if (string.IsNullOrWhiteSpace(value)) biographie = "Pas de biographie";
@ -39,7 +50,7 @@ namespace Model
} }
} }
} }
private string biographie; private string biographie = default!;
[DataMember] [DataMember]
public string Email public string Email
{ {
@ -55,7 +66,7 @@ namespace Model
else email = "Default"; else email = "Default";
} }
} }
private string email; private string email = default!;
[DataMember] [DataMember]
public string Password public string Password
{ {
@ -71,7 +82,7 @@ namespace Model
} }
} }
} }
private string password; private string password = default!;
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
@ -89,17 +100,6 @@ namespace Model
get; get;
private init; private init;
} }
[DataMember]
public string? UserImage
{
get => userImage;
private set
{
if (!string.IsNullOrWhiteSpace(value)) userImage = value;
else userImage = "no_cover.png";
}
}
private string? userImage;
public User(string userImage,string username, string biographie, string email, string password) public User(string userImage,string username, string biographie, string email, string password)
{ {
@ -111,7 +111,7 @@ namespace Model
else Biographie = biographie; else Biographie = biographie;
if (email == null) Email = "Default"; if (email == null) Email = "Default";
else Email = email; else Email = email;
if (password == null) throw new ArgumentNullException("password"); if (password == null) throw new ArgumentNullException(nameof(password));
else Password = password; else Password = password;
Followed_Games = new ObservableCollection<Game>(); Followed_Games = new ObservableCollection<Game>();
} }

@ -12,15 +12,15 @@ public partial class Create : ContentPage
private async void Creer_un_compte(object sender, EventArgs e) private async void Creer_un_compte(object sender, EventArgs e)
{ {
Error.Clear(); Error.Clear();
if (!string.IsNullOrWhiteSpace(Username.Text) || !string.IsNullOrWhiteSpace(Pswd.Text) || !string.IsNullOrWhiteSpace(Email.Text)) if (!(string.IsNullOrWhiteSpace(Username.Text) || string.IsNullOrWhiteSpace(Pswd.Text) || string.IsNullOrWhiteSpace(Email.Text)))
{ {
if (((App)App.Current).Manager.SearchUser(Username.Text) == null) if (((App)App.Current).Manager.SearchUser(Username.Text) == null)
{ {
Regex rg = new Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"); GeneratedRegexAttribute rg = new GeneratedRegexAttribute("^([a-zA-Z0-9_.])+@([a-zA-Z0-9_]+[.])+[a-zA-Z0-9_]{2,}$");
if (rg.IsMatch(Email.Text)) if (rg.Match(Email.Text))
{ {
rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$"); rg = new GeneratedRegexAttribute("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$");
if (rg.IsMatch(Pswd.Text)) if (rg.Match(Pswd.Text))
{ {
((App)App.Current).Manager.AddUsertoUserList(new("", Username.Text, "", Email.Text, Pswd.Text)); ((App)App.Current).Manager.AddUsertoUserList(new("", Username.Text, "", Email.Text, Pswd.Text));
((App)App.Current).Manager.CurrentUser = ((App)App.Current).Manager.SearchUser(Username.Text); ((App)App.Current).Manager.CurrentUser = ((App)App.Current).Manager.SearchUser(Username.Text);

@ -7,16 +7,11 @@ namespace StimStub
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
public class Stub : IPersistance public class Stub : IPersistance
{ {
public List<Game> Games public List<Game> Games { get; set; }
{
get { return games; }
set { games = value; }
}
private List<Game> games;
public Stub() public Stub()
{ {
Games = LoadGame(); Games = LoadGame() ?? new();
} }
public void SaveGame(List<Game> games) public void SaveGame(List<Game> games)

Loading…
Cancel
Save