-
Notifications
You must be signed in to change notification settings - Fork 222
Сахабутдинов Ильфир #184
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
base: master
Are you sure you want to change the base?
Сахабутдинов Ильфир #184
Conversation
| private static void HandleParseError(IEnumerable<CommandLineError> errs) | ||
| { | ||
| Console.WriteLine("Ошибка при настройке."); | ||
| Environment.Exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не очень хорошо что у приложения несколько точек выхода. Я бы назвал их внезапными. Будет неплохо, если прокинешь результат до main и вернешь его на выходтам.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поправил, теперь вывожу сообщения ошибок в консоль в классе TagsCloudContainerUi
| internal class WeigherWordSizer(IImageSettingsProvider imageSettingsProvider) : IWeigherWordSizer | ||
| { | ||
| public Result<IReadOnlyCollection<ViewWord>> CalculateWordSizes(IReadOnlyDictionary<string, int> wordFrequencies, | ||
| int minSize = 8, int maxSize = 24) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут бы проверку параметров добавить. Больше к тому, что если minSize будет больше maxSize, то new Font упадет с исключением, которое в этом классе не ловится.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавил
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если они оба отрицательные, то, наверное, конструктору шрифта тоже не понравится?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Согласен, не учел. Добавил проверку и тесты на эти случаи
| private const int DistanceLayersDifference = 1; | ||
| private const double BetweenAngleDifference = Math.PI / 36; | ||
|
|
||
| public Result<None> SetCenterPoint(Point center) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вроде бы, нет смысла возвращать Result, если тут не может возникнуть ошибка. Сложно представить ошибку при установке центра.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поправил
|
|
||
| public Result<Point> GetNextRectangleLocation(Size rectangleSize) | ||
| { | ||
| if (rectangleSize.Width == 0 || rectangleSize.Height == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Теоретически может быть и меньше нуля.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поправил
|
|
||
| private static Bitmap CreateImageMap(ImageSettings imageSettings) | ||
| { | ||
| var bitmap = new Bitmap(imageSettings.Size.Width, imageSettings.Size.Height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitmap - IDisposable, где-то бы его освободить...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавил освобождение в TagsCloudContainerUi
| IWordFormatter<WordDetails> wordFormatter) | ||
| : ITextPreprocessor | ||
| { | ||
| public Result<IReadOnlyDictionary<string, int>> GetWordFrequencies(string text, WordSettings settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Опять же, предположу, что во внутренностях этого метода ошибки возникнуть не может.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Переделал работу с анализатором. Теперь может упасть ошибка
| return new Error($"Файл по указанному пути '{filePath}' не существует."); | ||
| } | ||
|
|
||
| using var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Теоретически, тут может упасть с исключением. По многим поводам, например: файл мог исчезнуть в момент после проверки выше и это строкой, могут быть различные ошибки прав доступа, файл может быть залочен для чтения и т.п.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поправил
|
|
||
| internal sealed class WordReader : IWordReader | ||
| { | ||
| public Result<IReadOnlyCollection<string>> ReadWords(string text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В методе может возникнуть ошибка?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нет. Поправил
| var speechParts = validSpeechParts.ToArray(); | ||
| if (speechParts.Length == 0) | ||
| { | ||
| return new Error("Должен быть указан хотя бы одна доступная часть речи"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Должна быть указана"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поправил )
| "jpg" => ImageFormat.Jpeg, | ||
| "jpeg" => ImageFormat.Jpeg, | ||
| "bmp" => ImageFormat.Bmp, | ||
| _ => throw new ArgumentException($"Unsupported image format: {ImageFormatString}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Куда улетит это исключение?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В самый верх
| private static Result<None> HandleParseError(IEnumerable<CommandLineError> errs) | ||
| { | ||
| var errors = errs.Select(err => err.Tag.ToString()).ToList(); | ||
| return new Error($"При чтении опций произошла ошибка. Теги ошибок: {errors}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
При чтении опций произошла ошибка. Теги ошибок: System.Collections.Generic.List`1[System.String]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поправил
| .OnFail(error => | ||
| { | ||
| Console.WriteLine(error.Message); | ||
| Environment.Exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А что мешает вернуть ошибку ещё выше и вывести в консоль там?
Если говорить точнее, мне не нравится как ты выходишь из приложения. У этого метода есть свои особенности, и это не является нормальным способом выходить.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Перенес вывод сообщения выше. Спасибо за ссылку, учту это для себя
| internal class WeigherWordSizer(IImageSettingsProvider imageSettingsProvider) : IWeigherWordSizer | ||
| { | ||
| public Result<IReadOnlyCollection<ViewWord>> CalculateWordSizes(IReadOnlyDictionary<string, int> wordFrequencies, | ||
| int minSize = 8, int maxSize = 24) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если они оба отрицательные, то, наверное, конструктору шрифта тоже не понравится?
…кулятора размеров слов
@lev_shisterov