-
Notifications
You must be signed in to change notification settings - Fork 300
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
Большаков Николай #242
base: master
Are you sure you want to change the base?
Большаков Николай #242
Conversation
cs/Markdown/Md.cs
Outdated
|
||
public class Md : IStringProcessor | ||
{ | ||
private readonly ITagPairsFinder _tagPairsFinder; |
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.
В шарпе не принято именовать приватные переменные с _
cs/Markdown/Md.cs
Outdated
|
||
private Dictionary<IMdTag, List<SubstringReplacement>> GetTagsIndices(string mdString, IEnumerable<IMdTag> tags) | ||
{ | ||
var tagsIndices = tags.ToDictionary(tag => tag, tag => new List<SubstringReplacement>()); |
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.
Здесь можно сделать так:
tags.ToDictionary(tag => tag, _ => new List<SubstringReplacement>());
Всё равно не используешь tag в функции задающей value
cs/Markdown/Md.cs
Outdated
.ToDictionary(kv => kv.Key, kv => _tagPairsFinder.PairTags(mdString, kv.Value).ToList()); | ||
var tagPairs = _pairTagsIntersectionHandler | ||
.RemoveIntersections(pairedTags) | ||
.ToDictionary(kv => (IHtmlTagsPair)kv.Key, KeyValuePair => KeyValuePair.Value.AsEnumerable()); |
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.
Странноватое именование KeyValuePair следовало бы назвать keyValuePair
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.
В остальных случаях везде kv писал, тут случайно так назвал
{ | ||
for (var (i, j) = (0, 0); i < tagPositions.Length; i++) | ||
{ | ||
for (; lineBreakIndices[j] < tagPositions[i].EndIndex; j++) ; |
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.
Сложновато для восприятия выглядят такие циклы.
Лучше наверное использовать что-то вроде:
while(lineBreakIndices[j] < tagPositions[i].EndIndex) j++;
cs/Markdown/MdTags/ImageMdTag.cs
Outdated
{ | ||
private const string MdTag = "!"; | ||
|
||
private readonly LinkMdTag _linkMdTag = new(); |
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.
Снова именование переменных
cs/Markdown/TagSearchHelper.cs
Outdated
|
||
public static bool IsNumber(string str, int startIndex, out int length) | ||
{ | ||
for (length = 0; startIndex + length < str.Length && char.IsDigit(str[startIndex + length]); length++) ; |
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.
Ну опять-таки нет никакого смысла описывать подобную логику через for
- это очень неудобно читать. Используй while
cs/Markdown_Tests/Benchmark.cs
Outdated
internal class Benchmark | ||
{ | ||
public long MeasureMilliseconds( | ||
Action f, |
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.
f?
cs/Markdown_Tests/MdTests.cs
Outdated
|
||
public class MdTests | ||
{ | ||
private Md _md; |
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.
Ну и про именование не забывай
@masssha1308