Skip to content

Resolve Plutakhin tests#42

Open
plutakhin wants to merge 5 commits into
Restream:masterfrom
plutakhin:master
Open

Resolve Plutakhin tests#42
plutakhin wants to merge 5 commits into
Restream:masterfrom
plutakhin:master

Conversation

@plutakhin

Copy link
Copy Markdown

No description provided.

Comment thread .gitignore Outdated
/spec/reports/
/tmp/
/log/
/.idea No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

нужно настроить редактор так, чтобы в нем по сохранению в конце файла оставалась одна пустая строка

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

так же .idea - это файл, который создается твоей средой разработки. такие настройки выносятся в твой глобальный .gitignore, а не в .gitignore проекта

Comment thread test/plutakhin/arrays/solution.rb Outdated
class << self
def replace(array)
max = array.max
array.map! { |a| a >= 0 ? max : a }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

map! мутирует исходный массив, тебе тут это совершенно не нужно, можно использовать map без !

Comment thread test/plutakhin/arrays/solution.rb Outdated
value = array[mid]
return mid if value == query

if query < value

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

тут можно использовать тернарный оператор

Comment thread test/plutakhin/fp/solution.rb Outdated
def rating(films)
ratios = films.map do |film|
film['rating_kinopoisk'].to_f if !film['rating_kinopoisk'].to_f.zero? && !film['country'].nil? && film['country'].split(',').count > 1
end . compact

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

какие-то странные пробелы с точками

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

если какой-то блок заканчивается end, после него уже цепочку методов не строим.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

условие в if очень большое, строка плохо читается, можно вынести его в переменную или вспомогательный метод

Comment thread test/plutakhin/fp/solution.rb Outdated
end

def chars_count(films, threshold)
total = 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

вместо глобального счетчика можно использовать reduce

Comment thread test/plutakhin/fp/test.rb Outdated
# Посчитать средний рейтинг фильмов по версии кинопоиска у которых две или больше стран
# Фильмы у которых рейтиг не задан или равен 0 не учитывать в расчете среднего.
def test_rating
skip

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

тесты заскипаны, они не запускаются

Comment thread test/plutakhin/fp2/solution.rb Outdated
# Написать свою функцию my_compact
def my_compact
array = MyArray.new
for elm in self

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

тут можно использовать my_each вместо for. в обычной жизни вместо for всегда используется each

ignore_first = true
acc = first
end
index = 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

можно порефакторить и не использовать никаких счетчиков. также предлагаю пользоваться своими функциями типа my_each

Comment thread test/plutakhin/fp2/test.rb Outdated
end

def test_my_each
skip

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

тесты скипнуты, читай ридми

@plutakhin

Copy link
Copy Markdown
Author

Обновил реализацию.
В тесте с подсчетом букв "и" возможно закралась ошибка, разными способами подсчета достигалось другая сумма не соответствующая тесту

Comment thread test/plutakhin/fp/test.rb
array = CSV.readlines('./test/fixtures/films.csv', headers: true)

result = Plutakhin::Fp.chars_count(array, 5)
assert result == 891

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

да, значения в тесте неправильные, нужны 3966 и 42

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