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

Maria Cheprasova - 0 #31

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

Maria Cheprasova - 0 #31

wants to merge 9 commits into from

Conversation

moooll
Copy link

@moooll moooll commented Dec 9, 2018

Name

Maria Cheprasova

Homework#

0

Link to video with demo

https://www.youtube.com/watch?v=ecIWPzGEbFc

Comment

Level 1, 2 and 3

Copy link

@houndci-bot houndci-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: [/IrresponsibleMo...
Error: We found some problems with your configuration file: [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/UtilityFunction] key 'UtilityFunction:' is undefined.

else puts "#{arr_seek}"
end
puts "#{count_files} files were found"
end

Choose a reason for hiding this comment

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

Layout/TrailingBlankLines: Final newline missing.

puts "nothing"
else puts "#{arr_seek}"
end
puts "#{count_files} files were found"

Choose a reason for hiding this comment

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

Layout/IndentationConsistency: Inconsistent indentation detected.

end
if arr_seek.empty?
puts "nothing"
else puts "#{arr_seek}"

Choose a reason for hiding this comment

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

Layout/ElseAlignment: Align else with if.
Style/UnneededInterpolation: Prefer to_s over string interpolation.

end
end
if arr_seek.empty?
puts "nothing"

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

workbook.each do |worksheet_rows|
worksheet_rows.select { |row| row&.cells&.at(0)&.value }.each_with_index do |row, index|
if row&.cells[14]&.value==seek
arr_seek.push(row&.cells[0]&.value)

Choose a reason for hiding this comment

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

Lint/SafeNavigationChain: Do not chain ordinary method call after safe navigation operator.

end
end
arr_seek=Array.new
if num_rows!=0

Choose a reason for hiding this comment

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

Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Layout/SpaceAroundOperators: Surrounding space missing for operator !=.

ind_min=i
end
end
arr_seek=Array.new

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Surrounding space missing for operator =.
Style/EmptyLiteral: Use array literal [] instead of Array.new.

if arr_price[i]<min
min=arr_price[i]
ind_min=i
end

Choose a reason for hiding this comment

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

Layout/EndAlignment: end at 64, 4 is not aligned with if at 61, 2.

end
if arr_price[i]<min
min=arr_price[i]
ind_min=i

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Surrounding space missing for operator =.

ind_max=i
end
if arr_price[i]<min
min=arr_price[i]

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Surrounding space missing for operator =.

@RGBD RGBD self-assigned this Dec 9, 2018
Copy link
Collaborator

@RGBD RGBD left a comment

Choose a reason for hiding this comment

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

Таблицы надо удалить из репозитория

@@ -0,0 +1,10 @@
[LocalizedFileNames]
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove file

puts " #{item_name}: #{price}"
end
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix indent

Copy link

@houndci-bot houndci-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: [/IrresponsibleMo...
Error: We found some problems with your configuration file: [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/UtilityFunction] key 'UtilityFunction:' is undefined.

puts 'nothing'
else
arr_seek.to_s
puts "#{arr_seek.to_s}"

Choose a reason for hiding this comment

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

Style/UnneededInterpolation: Prefer to_s over string interpolation.
Lint/StringConversionInInterpolation: Redundant use of Object#to_s in interpolation.

ind_min = i
end
end
arr_seek = Array.new

Choose a reason for hiding this comment

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

Style/EmptyLiteral: Use array literal [] instead of Array.new.

num_rows = 0
arr_name = Array.new
arr_price = Array.new
arr_date = Array.new

Choose a reason for hiding this comment

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

Style/EmptyLiteral: Use array literal [] instead of Array.new.

count_files = 0
num_rows = 0
arr_name = Array.new
arr_price = Array.new

Choose a reason for hiding this comment

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

Style/EmptyLiteral: Use array literal [] instead of Array.new.

seek = price_to_seek
count_files = 0
num_rows = 0
arr_name = Array.new

Choose a reason for hiding this comment

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

Style/EmptyLiteral: Use array literal [] instead of Array.new.

Maria Cheprasova/New folder/Gemfile Outdated Show resolved Hide resolved
Copy link

@houndci-bot houndci-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: [/IrresponsibleMo...
Error: We found some problems with your configuration file: [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/UtilityFunction] key 'UtilityFunction:' is undefined.

Copy link

@houndci-bot houndci-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: [/IrresponsibleMo...
Error: We found some problems with your configuration file: [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/UtilityFunction] key 'UtilityFunction:' is undefined.

Copy link

@houndci-bot houndci-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: [/IrresponsibleMo...
Error: We found some problems with your configuration file: [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/UtilityFunction] key 'UtilityFunction:' is undefined.

Copy link

@houndci-bot houndci-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: [/IrresponsibleMo...
Error: We found some problems with your configuration file: [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/UtilityFunction] key 'UtilityFunction:' is undefined.

puts "Lowest #{min} #{arr_date[ind_min]}"
puts ", highest was #{max} #{arr_date[ind_max]}"
end
puts 'You can also buy '.chomp
Copy link
Collaborator

Choose a reason for hiding this comment

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

chomp not needed

ans = gets.chomp
worksheets.each do |worksheet_rows|
worksheet_rows.select { |row| row.at(0).value }.each_with_index do |row, _|
row.each_with_index do |_, cell_index|
Copy link
Collaborator

Choose a reason for hiding this comment

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

you don't need to iterate over row, you only use row[14] and row[0]

end
end
end
seek = price_to_seek
Copy link
Collaborator

Choose a reason for hiding this comment

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

you don't need another variable, just use price_to_seek

ind_max = 0
max = arr_price[0]
min = arr_price[0]
arr_price.each_index do |i|
Copy link
Collaborator

Choose a reason for hiding this comment

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

ind_min = arr_price.index(arr_price.min)
min = arr_price[ind_min]

Copy link
Author

@moooll moooll Dec 11, 2018

Choose a reason for hiding this comment

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

These two are interchangeable?
+What does this statement mean? (arr_price.min)

Copy link
Collaborator

@RGBD RGBD Dec 11, 2018

Choose a reason for hiding this comment

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

2.5.1 (main):0 > arr_price = ["f", "c", "d", "f", "h", "b", "i"];
2.5.1 (main):0 > arr_price.index("f")
=> 0
2.5.1 (main):0 > arr_price.index("d")
=> 2
2.5.1 (main):0 > arr_price.min
=> "b"

https://ruby-doc.org/core-2.2.0/Array.html#method-i-index
https://ruby-doc.org/core-2.5.3/Enumerable.html#method-i-min

Copy link
Author

@moooll moooll Dec 14, 2018

Choose a reason for hiding this comment

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

Sorry, but houndci-bot left such a remark for me "Error: We found some problems with your configuration file: [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/UtilityFunction] key 'UtilityFunction:' is undefined."
as I understood one of te errors happened due to several duplicate parts of code. but I don't know exactly where they are. mb u can help me with the reason why this error happens?

ind_min = i
end
end
arr_seek []
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't work, did you mean arr_seek = []?

end
puts 'You can also buy '.chomp
workbook.each do |worksheet_rows|
worksheet_rows.select { |row| row.at(0).value }.each_with_index do |row, _|
Copy link
Collaborator

Choose a reason for hiding this comment

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

use each if you don't care about index

Copy link

@houndci-bot houndci-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: [/IrresponsibleMo...
Error: We found some problems with your configuration file: [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/UtilityFunction] key 'UtilityFunction:' is undefined.

item_name = row[0].value
price = row[14].value || 'unknown'
price_to_seek = price
puts " #{item_name}: #{price}"

Choose a reason for hiding this comment

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

Layout/IndentationConsistency: Inconsistent indentation detected.


item_name = row[0].value
price = row[14].value || 'unknown'
price_to_seek = price

Choose a reason for hiding this comment

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

Layout/IndentationConsistency: Inconsistent indentation detected.

next if row[0].value.include?(ans)

item_name = row[0].value
price = row[14].value || 'unknown'

Choose a reason for hiding this comment

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

Layout/IndentationConsistency: Inconsistent indentation detected.

Copy link

@houndci-bot houndci-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: [/IrresponsibleMo...
Error: We found some problems with your configuration file: [/IrresponsibleModule] key 'IrresponsibleModule:' is undefined., [/DuplicateMethodCall] key 'DuplicateMethodCall:' is undefined., [/UtilityFunction] key 'UtilityFunction:' is undefined.

Copy link
Collaborator

@RGBD RGBD left a comment

Choose a reason for hiding this comment

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

Couldn't run the program.
Please, check your code before commit.

@@ -0,0 +1,4 @@
source 'https://rubygems.org'

gem 'find'
Copy link
Collaborator

Choose a reason for hiding this comment

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

gem not found

% bundle install
Fetching gem metadata from https://rubygems.org/..............
Fetching gem metadata from https://rubygems.org/.
Could not find gem 'find' in any of the gem sources listed in your Gemfile.

puts 'What price are you looking for?'
ans = gets
worksheets.each do |worksheet_rows|
worksheet_rows.select { |row| row.at(0).value }.each do |row|
Copy link
Collaborator

Choose a reason for hiding this comment

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

What price are you looking for?
Соль
Traceback (most recent call last):
        7: from lvl1.rb:8:in `<main>'
        6: from lvl1.rb:8:in `each'
        5: from lvl1.rb:9:in `block in <main>'
        4: from lvl1.rb:9:in `select'
        3: from /home/oleg/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/rubyXL-3.3.31/lib/rubyXL/worksheet.rb:23:in `each'
        2: from /home/oleg/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/rubyXL-3.3.31/lib/rubyXL/worksheet.rb:23:in `each'
        1: from /home/oleg/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/rubyXL-3.3.31/lib/rubyXL/worksheet.rb:23:in `block in each'
lvl1.rb:9:in `block (2 levels) in <main>': undefined method `at' for #<RubyXL::Row:0x000055f6c3c9e158> (NoMethodError)

ans = gets
worksheets.each do |worksheet_rows|
worksheet_rows.select { |row| row.at(0).value }.each do |row|
next if cell_index.positive?
Copy link
Collaborator

Choose a reason for hiding this comment

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

cell_index unedfined local variable

workbook = RubyXL::Parser.parse './data/Average_prices(serv)-10-2018.xlsx'
worksheets = workbook.worksheets
puts 'What price are you looking for?'
ans = gets
Copy link
Collaborator

Choose a reason for hiding this comment

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

gets.chomp

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.

3 participants