Skip to content

Solution - #3

Open
dmssssk wants to merge 6 commits into
MindHardt:masterfrom
dmssssk:solution
Open

Solution#3
dmssssk wants to merge 6 commits into
MindHardt:masterfrom
dmssssk:solution

Conversation

@dmssssk

@dmssssk dmssssk commented Dec 27, 2025

Copy link
Copy Markdown

Debug.cs был для дебага, не знаю как удалить его из коммита

Comment thread App/Input.cs Outdated



// while (valid is false)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Комментариев в репозитории быть не должно

Comment thread App/Input.cs Outdated

var validResult = result.Where(x => IsValidUrl(x));

if (validResult.Count() == 0)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

За счёт вызова Count() и затем ToArray() ты итерируешь дважды, то есть у тебя дважды выполняется IsValidUrl для каждого элемента массива. Это нежелательно, лучше заранее материализовать запрос (сделать из него массив/лист) и затем проверять его размер

Comment thread App/Debug.cs Outdated
" https://un1ver5e.ru/api/files/rqdszqht.sjz.txt https://un1ver5e.ru/api/files/xujzw3wz.j2r.txt" +
" https://un1ver5e.ru/api/files/o1apoh5j.bdw.txt";

public static FileInfo GetOutFileName()

@MindHardt MindHardt Dec 29, 2025

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Название метода некорректное, он возвращает не FileName
  2. Его суть тоже непонятна, что и зачем он делает?

Comment thread App/Debug.cs Outdated

public static class Debug
{
public static string Urls =

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем это поле в этом классе? Оно не используется в нём + публичные поля не readonly это плохо, так делать не нужно

Comment thread App/Input.cs Outdated
}

private static bool IsValidUri(string uri) => uri.StartsWith("https://");
private static bool IsValidUrl(string uri) => uri.StartsWith("https://");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эта проверка не валидна, у URL более сложные правила валидации чем просто startswith

Comment thread App/Input.cs Outdated
{
Console.Write($"файл {file.Name} уже существует, перезаписать? y/n: ");

char answer = Console.ReadLine()!.ToLower()[0];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не надо считывать строку если тебе нужен только 1 символ - используй Console.ReadKey()

Comment thread App/Input.cs Outdated
if (answer == 'y')
{
File.Delete(file.FullName);
using (File.Create(file.FullName)) { }

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это зачем?

Comment thread App/StreamReaderUrl.cs Outdated

public class StreamReaderUrl
{
private StreamReader _reader;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А Dispose'ить этот стримридер кто будет?

Comment thread App/StreamReaderUrl.cs Outdated

public StreamReaderUrl(HttpClient http, string url)
{
_reader = new StreamReader(http.GetStreamAsync(url).GetAwaiter().GetResult());

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetAwaiter().GetResult() это охренительно плохо - ты превращаешь асинхронный код в синхронный и блокирующий без какой-либо причины. Нужно пересмотреть архитектуру.

Comment thread App/Program.cs Outdated
var isDone = new bool[urls.Length];
string line;

while (!isDone.All(x => x))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтобы последовательно выполнить пачку задач тебе не нужна магия с массивом bool, можно просто пройтись циклом по задачам

@MindHardt MindHardt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Первое ревью

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants