Skip to content
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

Pavel_Borisov - 2 #59

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open

Pavel_Borisov - 2 #59

wants to merge 21 commits into from

Conversation

ashpb
Copy link
Contributor

@ashpb ashpb commented May 11, 2021

Фамилия Имя

Борисов Павел

Email

[email protected]

Номер домашнего задания

2

Ссылка на видео с демо работы

asciicast

Комментарии

Написал MVP – вся основная функциональность реализована, но еще есть что доработать:

  • Не успел разобраться с многопоточностью, а она там очень даже нужна для ускорения процесса;
  • Архитектуру хотелось бы сделать попроще и покрасивее;
  • Тесты, по-хорошему, не должны ходить в сеть (не успел разобраться, как использовать стабы/моки, чтобы этого избежать).

Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Error: We found some problems with your configuration file: [/Attribute] key ...
Error: We found some problems with your configuration file: [/Attribute] key 'Attribute:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/FeatureEnvy] key 'FeatureEnvy:' is undefined., [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/PrimaDonnaMethod] key 'PrimaDonnaMethod:' is undefined., [/TooManyStatements] key 'TooManyStatements:' is undefined., [/app/workers] key 'app/workers:' is undefined., [/db/migrate] key 'db/migrate:' is undefined.

Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Error: We found some problems with your configuration file: [/Attribute] key ...
Error: We found some problems with your configuration file: [/Attribute] key 'Attribute:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/FeatureEnvy] key 'FeatureEnvy:' is undefined., [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/PrimaDonnaMethod] key 'PrimaDonnaMethod:' is undefined., [/TooManyStatements] key 'TooManyStatements:' is undefined., [/app/workers] key 'app/workers:' is undefined., [/db/migrate] key 'db/migrate:' is undefined.

Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Error: We found some problems with your configuration file: [/Attribute] key ...
Error: We found some problems with your configuration file: [/Attribute] key 'Attribute:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/FeatureEnvy] key 'FeatureEnvy:' is undefined., [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/PrimaDonnaMethod] key 'PrimaDonnaMethod:' is undefined., [/TooManyStatements] key 'TooManyStatements:' is undefined., [/app/workers] key 'app/workers:' is undefined., [/db/migrate] key 'db/migrate:' is undefined.

@ashpb ashpb changed the title Pavel Borisov - 2 Pavel_Borisov - 2 May 12, 2021
Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Error: We found some problems with your configuration file: [/Attribute] key ...
Error: We found some problems with your configuration file: [/Attribute] key 'Attribute:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/FeatureEnvy] key 'FeatureEnvy:' is undefined., [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/PrimaDonnaMethod] key 'PrimaDonnaMethod:' is undefined., [/TooManyStatements] key 'TooManyStatements:' is undefined., [/app/workers] key 'app/workers:' is undefined., [/db/migrate] key 'db/migrate:' is undefined.

@mirterious mirterious self-assigned this May 14, 2021
Copy link
Contributor

@mirterious mirterious left a comment

Choose a reason for hiding this comment

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

Нужно починить рубокоп, попробуй сребейзится на мастер


require_relative 'lib/machinery'

command_line = CliParser.new do |opts|
Copy link
Contributor

Choose a reason for hiding this comment

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

Это не command_line, это - parser

@@ -0,0 +1,145 @@
# frozen_string_literal: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Для каждого класса необходимо создать отдельный файл. Это очень помогает в навигации по приложению и в чтении кода

Comment on lines +23 to +29
def to_s
@opt_parser.to_s
end

def usage
to_s
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Думаю, лучше объединить это в один метод

Comment on lines +19 to +20
@opt_parser.parse!(into: @options)
@args = @opt_parser.instance_variable_get(:@default_argv)
Copy link
Contributor

Choose a reason for hiding this comment

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

После того, как объявлен attr_reader для инстанс переменных, можно использовать их без @, а-ля args, options etc

Comment on lines +66 to +68
http = Net::HTTP.new(@domain)
http.open_timeout = 1
http.read_timeout = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Можно вынести создание http-клиента в отдельный метод, например client. Это сократит метод timed_http_request и упростит взаимодействие с клиентом(например, если нужно будет его переиспользовать)

end

def result
case @status
Copy link
Contributor

Choose a reason for hiding this comment

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

Та же история с attr_reader.

Comment on lines +45 to +47
@status = :errored
cause = ('Timeout' if e.is_a? Timeout::Error) || e.cause
@error_message = "ERROR (#{cause})"
Copy link
Contributor

Choose a reason for hiding this comment

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

Здесь нужно обрабатывать ошибки по отдельности, например:

def check!
  # begin в начале метода ставить не обязательно
  timed_http_request
rescue Timeout::Error => timeout_exception
  @status = :errored
  @error_message = "ERROR Timeout"
rescue => e
  p "Something went wrong: #{e.message}"
end

cause = ('Timeout' if e.is_a? Timeout::Error) || e.cause
@error_message = "ERROR (#{cause})"
end
self
Copy link
Contributor

Choose a reason for hiding this comment

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

Зачем возвращаешь self?


domain_list_filename = command_line.args.first

if domain_list_filename.nil? || !File.exist?(domain_list_filename)
Copy link
Contributor

Choose a reason for hiding this comment

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

.nil? можно опустить, если конечно тебе не нужно, чтобы он был именно nil

domains.process! do |percent, domain|
print "\e[1000D\e[0K#{percent}% complete – now checking #{domain}"
end
print "\e[1000D\e[0K"
Copy link
Contributor

Choose a reason for hiding this comment

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

Вынеси эту штуку в константу, а то довольно тяжело понять, что это такое)

Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Error: We found some problems with your configuration file: [/Attribute] key ...
Error: We found some problems with your configuration file: [/Attribute] key 'Attribute:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/FeatureEnvy] key 'FeatureEnvy:' is undefined., [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/PrimaDonnaMethod] key 'PrimaDonnaMethod:' is undefined., [/TooManyStatements] key 'TooManyStatements:' is undefined., [/app/workers] key 'app/workers:' is undefined., [/db/migrate] key 'db/migrate:' is undefined.

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.

4 participants