-
Notifications
You must be signed in to change notification settings - Fork 21
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
base: master
Are you sure you want to change the base?
Conversation
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.
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.
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.
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.
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.
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.
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.
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.
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.
Нужно починить рубокоп, попробуй сребейзится на мастер
|
||
require_relative 'lib/machinery' | ||
|
||
command_line = CliParser.new do |opts| |
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.
Это не command_line
, это - parser
@@ -0,0 +1,145 @@ | |||
# frozen_string_literal: true |
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.
Для каждого класса необходимо создать отдельный файл. Это очень помогает в навигации по приложению и в чтении кода
def to_s | ||
@opt_parser.to_s | ||
end | ||
|
||
def usage | ||
to_s | ||
end |
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.
Думаю, лучше объединить это в один метод
@opt_parser.parse!(into: @options) | ||
@args = @opt_parser.instance_variable_get(:@default_argv) |
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.
После того, как объявлен attr_reader
для инстанс переменных, можно использовать их без @
, а-ля args
, options
etc
http = Net::HTTP.new(@domain) | ||
http.open_timeout = 1 | ||
http.read_timeout = 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.
Можно вынести создание http-клиента в отдельный метод, например client
. Это сократит метод timed_http_request
и упростит взаимодействие с клиентом(например, если нужно будет его переиспользовать)
end | ||
|
||
def result | ||
case @status |
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.
Та же история с attr_reader
.
@status = :errored | ||
cause = ('Timeout' if e.is_a? Timeout::Error) || e.cause | ||
@error_message = "ERROR (#{cause})" |
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.
Здесь нужно обрабатывать ошибки по отдельности, например:
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 |
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.
Зачем возвращаешь self
?
|
||
domain_list_filename = command_line.args.first | ||
|
||
if domain_list_filename.nil? || !File.exist?(domain_list_filename) |
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.
.nil?
можно опустить, если конечно тебе не нужно, чтобы он был именно nil
domains.process! do |percent, domain| | ||
print "\e[1000D\e[0K#{percent}% complete – now checking #{domain}" | ||
end | ||
print "\e[1000D\e[0K" |
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.
Вынеси эту штуку в константу, а то довольно тяжело понять, что это такое)
Set up github actions
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.
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.
Фамилия Имя
Борисов Павел
Email
[email protected]
Номер домашнего задания
2
Ссылка на видео с демо работы
Комментарии
Написал MVP – вся основная функциональность реализована, но еще есть что доработать: