fix by sonar code smell
continuous-integration/drone/push Build is passing Details

pull/19/head
Matheo THIERRY 2 years ago
parent d3b0e7b0a6
commit 0e7f6e2f4a

@ -30,4 +30,15 @@ namespace Biblioteque_de_Class
{ {
} }
} }
public class FileException : Exception
{
public FileException(string message) : base(message)
{
}
}
} }

@ -25,11 +25,11 @@ namespace Biblioteque_de_Class
private DateOnly CreationDate { get; } private DateOnly CreationDate { get; }
private DateOnly ModificationDate { get; set; } private DateOnly ModificationDate { get; set; }
private List<NoteImage> ImageList; private readonly List<NoteImage> ImageList;
private string TextLine; private string TextLine;
private List<User> Collaborators; private readonly List<User> Collaborators;
private List<User> Editors; private readonly List<User> Editors;
private User Owner; private readonly User Owner;
public Note(string name, string logoPath, User owner) public Note(string name, string logoPath, User owner)
{ {

@ -4,7 +4,7 @@ namespace Biblioteque_de_Class
{ {
public class PersistenceManager public class PersistenceManager
{ {
private IManager persistence; private readonly IManager persistence;
public PersistenceManager(IManager pers) public PersistenceManager(IManager pers)
{ {

@ -9,7 +9,7 @@ namespace Biblioteque_de_Class
public class Theme public class Theme
{ {
private string Name { get; set; } private string Name { get; set; }
private List<string> ColorList; private readonly List<string> ColorList;
public Theme(string name, List<string> colorList) public Theme(string name, List<string> colorList)
{ {

@ -37,23 +37,22 @@ namespace Notus_Persistance
{ {
if (File.Exists(DatabaseDataFilePath)) if (File.Exists(DatabaseDataFilePath))
{ {
Database database1;
using (FileStream fileStream = File.OpenRead(DatabaseDataFilePath)) using (FileStream fileStream = File.OpenRead(DatabaseDataFilePath))
{ {
Database? database = (Database?)DatabasejsonSerializer.ReadObject(fileStream); Database? database = (Database?)DatabasejsonSerializer.ReadObject(fileStream);
if (database == null) if (database == null)
{ {
throw new Exception("Failed to load database. The loaded object is null."); throw new FileException("Failed to load database. The loaded object is null.");
} }
else else
{ {
return database1 = database; return database;
} }
} }
} }
else else
{ {
throw new Exception("No data file found."); throw new FileException("No data file found.");
} }
} }
@ -82,7 +81,7 @@ namespace Notus_Persistance
User? user = (User?)UserjsonSerializer.ReadObject(fileStream); User? user = (User?)UserjsonSerializer.ReadObject(fileStream);
if (user == null) if (user == null)
{ {
throw new Exception("Failed to load database. The loaded object is null."); throw new FileException("Failed to load database. The loaded object is null.");
} }
else else
{ {
@ -92,7 +91,7 @@ namespace Notus_Persistance
} }
else else
{ {
throw new Exception("No userfile find"); throw new FileException("No userfile find");
} }
} }
} }

Loading…
Cancel
Save