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

Kirill Hryvicki - 0 #20

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

Kirill Hryvicki - 0 #20

wants to merge 23 commits into from

Conversation

ypsl
Copy link

@ypsl ypsl commented Dec 8, 2018

Name

Kirill Hryvicki

Homework#

0

Link to video with demo

Comment

All levels

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.

end
end

main()

Choose a reason for hiding this comment

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

Style/MethodCallWithoutArgsParentheses: Do not use parentheses for method calls with no arguments.
Layout/TrailingBlankLines: Final newline missing.

puts "For similar price you also can afford"
puts similarProducts
end

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

if similarProducts.length == 0
puts "No products for similar price"
else
puts "For similar price you also can afford"

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

similarProducts = getSimilarPriceProducts(recentPriceData, products)

if similarProducts.length == 0
puts "No products for similar price"

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


similarProducts = getSimilarPriceProducts(recentPriceData, products)

if similarProducts.length == 0

Choose a reason for hiding this comment

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

Style/NumericPredicate: Use similarProducts.length.zero? instead of similarProducts.length == 0.
Style/ZeroLengthPredicate: Use empty? instead of length == 0.

puts ""
recentPriceData = getRecentPriceData(key, products, monthMap)
puts key.capitalize + " is " + recentPriceData["price"].to_s + " BYN in Minsk these days."
minPrice = getMinPrice(products[key])

Choose a reason for hiding this comment

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

Naming/VariableName: Use snake_case for variable names.

keys.each{|key|
puts ""
recentPriceData = getRecentPriceData(key, products, monthMap)
puts key.capitalize + " is " + recentPriceData["price"].to_s + " BYN in Minsk these days."

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.

else
keys.each{|key|
puts ""
recentPriceData = getRecentPriceData(key, products, monthMap)

Choose a reason for hiding this comment

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

Naming/VariableName: Use snake_case for variable names.

puts word.capitalize + " can not be found in database"
else
keys.each{|key|
puts ""

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

if keys.length == 0
puts word.capitalize + " can not be found in database"
else
keys.each{|key|

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceInsideBlockBraces: Space between { and | missing.
Style/BlockDelimiters: Avoid using {...} for multi-line blocks.

small fixes
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 "For similar price you also can afford"
puts similarProducts
end
}

Choose a reason for hiding this comment

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

Layout/BlockAlignment: } at 236, 8 is not aligned with keys.each { |key| at 222, 6.

if similarProducts.empty? == 0
puts "No products for similar price"
else
puts "For similar price you also can afford"

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.

puts "Maximum was on " + maxPrice["year"] + "/" + monthMap[maxPrice["month"]].to_s + " at price " + maxPrice["price"].to_s + " BYN"
similarProducts = getSimilarPriceProducts(recentPriceData, products)
if similarProducts.empty? == 0
puts "No products for similar price"

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.

maxPrice = getMaxPrice(products[key])
puts "Maximum was on " + maxPrice["year"] + "/" + monthMap[maxPrice["month"]].to_s + " at price " + maxPrice["price"].to_s + " BYN"
similarProducts = getSimilarPriceProducts(recentPriceData, products)
if similarProducts.empty? == 0

Choose a reason for hiding this comment

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

Style/NumericPredicate: Use similarProducts.empty?.zero? instead of similarProducts.empty? == 0.

puts "Lowest was on " + minPrice["year"] + "/" + monthMap[minPrice["month"]].to_s + " at price " + minPrice["price"].to_s + " BYN"
maxPrice = getMaxPrice(products[key])
puts "Maximum was on " + maxPrice["year"] + "/" + monthMap[maxPrice["month"]].to_s + " at price " + maxPrice["price"].to_s + " BYN"
similarProducts = getSimilarPriceProducts(recentPriceData, products)

Choose a reason for hiding this comment

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

Naming/VariableName: Use snake_case for variable names.

if keys.length == 0
puts word.capitalize + " can not be found in database"
else
keys.each { |key|

Choose a reason for hiding this comment

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

Style/BlockDelimiters: Avoid using {...} for multi-line blocks.

word = gets.chomp.downcase
keys = findKeys(word, products)
if keys.length == 0
puts word.capitalize + " can not be found in database"

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.

puts "What price are you looking for?"
word = gets.chomp.downcase
keys = findKeys(word, products)
if keys.length == 0

Choose a reason for hiding this comment

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

Style/NumericPredicate: Use keys.length.zero? instead of keys.length == 0.
Style/ZeroLengthPredicate: Use empty? instead of length == 0.

}

while true
puts "What price are you looking for?"

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.

end
}

while true

Choose a reason for hiding this comment

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

Style/InfiniteLoop: Use Kernel#loop for infinite loops.
Lint/LiteralAsCondition: Literal true appeared as a condition.

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.


max_price = getMaxPrice(products[key])
puts 'Maximum was on ' + max_price["year"] + '/' + month_map[max_price["month"]].to_s +
' at price ' + max_price["price"].to_s + ' BYN'

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


min_price = getMinPrice(products[key])
puts 'Lowest was on ' + min_price["year"] + '/' + month_map[min_price["month"]].to_s +
' at price ' + min_price["price"].to_s + ' BYN'

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

puts key.capitalize + ' is ' + recent_price_data["price"].to_s + ' BYN in Minsk these days.'

min_price = getMinPrice(products[key])
puts 'Lowest was on ' + min_price["year"] + '/' + month_map[min_price["month"]].to_s +

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.

keys.each { |key|
recent_price_data = getRecentPriceData(key, products, month_map)
puts ''
puts key.capitalize + ' is ' + recent_price_data["price"].to_s + ' BYN in Minsk these days.'

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.


loop do
puts 'What price are you looking for?'
word = gets.chomp.downcase #.encode("UTF-8")

Choose a reason for hiding this comment

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

Layout/ExtraSpacing: Unnecessary spacing detected.
Layout/LeadingCommentSpace: Missing space after #.

'ноябрь' => 11,
'декабрь' => 12,
}

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

'сентябрь' => 9,
'октябрь' => 10,
'ноябрь' => 11,
'декабрь' => 12,

Choose a reason for hiding this comment

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

Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.

return result
end

def main

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for main is too high. [61.07/15]
Metrics/MethodLength: Method has too many lines. [50/10]

result.push(product)
end
}
return result

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.

if !product_data[year][month]
next
end
if product_data[year][month]["Minsk"] == price && product != origin_product

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 &&/||.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

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.


max_price = getMaxPrice(products[key])
puts 'Maximum was on ' + max_price['year'] + '/' + month_map[max_price['month']].to_s +
' at price ' + max_price['price'].to_s + ' BYN'

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines.


min_price = getMinPrice(products[key])
puts 'Lowest was on ' + min_price['year'] + '/' + month_map[min_price['month']].to_s +
' at price ' + min_price['price'].to_s + ' BYN'

Choose a reason for hiding this comment

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

Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines.


file_paths.each do |file_path|
file_instance = getFileInstance(file_path)
fetchProductsData(file_instance, products, regions) if file_instance

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

return result
end

def main

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for main is too high. [60.09/15]
Metrics/MethodLength: Method has too many lines. [48/10]


products.each { |product, product_data|
next if !product_data[year]
next if !product_data[year][month]

Choose a reason for hiding this comment

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

Style/NegatedIf: Favor unless over if for negative conditions.

return result
end

def getMaxPrice(hash)

Choose a reason for hiding this comment

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

Metrics/MethodLength: Method has too many lines. [19/10]
Naming/MethodName: Use snake_case for method names.

result['price'] = min_year_price
end
end
return result

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.

result['month'] = month
end
end
if min_month_price < min_year_price

Choose a reason for hiding this comment

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

Style/Next: Use next to skip iteration.

min_month_price = 9999999999999
year_hash.each do |month, month_hash|
price = month_hash['Minsk']
next if !price

Choose a reason for hiding this comment

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

Style/NegatedIf: Favor unless over if for negative conditions.
Layout/TrailingWhitespace: Trailing whitespace detected.

min_year_price = 9999999999999

hash.each do |year, year_hash|
min_month_price = 9999999999999

Choose a reason for hiding this comment

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

Style/NumericLiterals: Use underscores(_) as decimal mark and separate every 3 digits with them.

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.


def getMinPrice(hash)
result = {}
min_year_price = 9999999999999

Choose a reason for hiding this comment

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

Style/NumericLiterals: Use underscores(_) as decimal mark and separate every 3 digits with them.

}
end

def getMinPrice(hash)

Choose a reason for hiding this comment

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

Metrics/MethodLength: Method has too many lines. [19/10]
Naming/MethodName: Use snake_case for method names.

'year' => year_key,
'month' => month_key,
'product' => key
}

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

month_key = product_month_data.keys.max{ |a,b| month_map[a].to_i <=> month_map[b].to_i}
end

return {

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.

if product_month_data[current_month]
month_key = current_month
else
month_key = product_month_data.keys.max{ |a,b| month_map[a].to_i <=> month_map[b].to_i}

Choose a reason for hiding this comment

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

Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceAfterComma: Space missing after comma.
Layout/SpaceInsideBlockBraces: Space missing inside }.

if val
result = val.to_f
result = result / 10000 if year.to_i < 2017
return result.round(2)

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.

def formatValue(val, year)
if val
result = val.to_f
result = result / 10000 if year.to_i < 2017

Choose a reason for hiding this comment

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

Style/SelfAssignment: Use self-assignment shorthand /=.
Style/NumericLiterals: Use underscores(_) as decimal mark and separate every 3 digits with them.

end

def formatValue(val, year)
if val

Choose a reason for hiding this comment

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

Style/GuardClause: Use a guard clause instead of wrapping the code inside a conditional expression.

end
end

def formatValue(val, year)

Choose a reason for hiding this comment

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

Naming/MethodName: Use snake_case for method names.

key = file_instance.cell('A', n).strip.downcase

products[key] = {} if !products[key]
products[key][year] = {} if !products[key][year]

Choose a reason for hiding this comment

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

Style/NegatedIf: Favor unless over if for negative conditions.

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.

month = file_instance.cell('A', 3).split(' ')[1]
key = file_instance.cell('A', n).strip.downcase

products[key] = {} if !products[key]

Choose a reason for hiding this comment

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

Style/NegatedIf: Favor unless over if for negative conditions.


def fetchProductsData(file_instance, products, regions)
for n in 9..file_instance.last_row
next if file_instance.cell('E', n) == nil

Choose a reason for hiding this comment

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

Style/NilComparison: Prefer the use of the nil? predicate.

end

def fetchProductsData(file_instance, products, regions)
for n in 9..file_instance.last_row

Choose a reason for hiding this comment

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

Style/For: Prefer each over for.

return result
end

def fetchProductsData(file_instance, products, regions)

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for fetchProductsData is too high. [41.79/15]
Metrics/MethodLength: Method has too many lines. [17/10]
Naming/MethodName: Use snake_case for method names.

products.keys.each { |key|
result.push(key) if(key.include?(word))
}
return result

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.

require 'roo'
require 'roo-xls'

def getFileInstance(file_path)

Choose a reason for hiding this comment

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

Metrics/MethodLength: Method has too many lines. [14/10]
Naming/MethodName: Use snake_case for method names.

end
end
end
end

Choose a reason for hiding this comment

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

Lint/Syntax: unexpected token kEND

puts key.capitalize+' is '+recent_price_data['price'].to_s+' BYN in Minsk these days.'

min_price = get_min_price(products[key])
puts 'Lowest was on '+min_price['year']+'/'+month_map[min_price['month']].to_s +' at price '+min_price['price'].to_s+' BYN'

Choose a reason for hiding this comment

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

Lint/Syntax: +' interpreted as argument prefix

end
download = open(f_link)
IO.copy_stream(download, "./data/#{download.base_uri.to_s.split('/')[-1]}")
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.

else
f_link = 'http://www.belstat.gov.by' + str_link
end
download = open(f_link)

Choose a reason for hiding this comment

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

Security/Open: The use of Kernel#open is a serious security risk.

6
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.

min_price = get_min_price(products[key])
puts 'Lowest was on '+min_price['year']+'/'+month_map[min_price['month']].to_s+' at price '+min_price['price'].to_s+' BYN'
max_price = get_max_price(products[key])
puts 'Maximum was on '+max_price['year']+'/'+month_map[max_price['month']].to_s+' at price '+max_price['price'].to_s+' BYN'

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 +.
Metrics/LineLength: Line is too long. [129/120]

puts ''
puts key.capitalize+' is '+recent_price_data['price'].to_s+' BYN in Minsk these days.'
min_price = get_min_price(products[key])
puts 'Lowest was on '+min_price['year']+'/'+month_map[min_price['month']].to_s+' at price '+min_price['price'].to_s+' BYN'

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 +.
Metrics/LineLength: Line is too long. [128/120]

keys.each do |key|
recent_price_data = get_recent_price_data(key, products, month_map)
puts ''
puts key.capitalize+' is '+recent_price_data['price'].to_s+' BYN in Minsk these days.'

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 +.

'сентябрь' => 9,
'октябрь' => 10,
'ноябрь' => 11,
'декабрь' => 12,

Choose a reason for hiding this comment

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

Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.

result
end


Choose a reason for hiding this comment

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

Layout/EmptyLines: Extra blank line detected.

def find_max_month(year_hash, max_month_price = 0, max_month = nil)
year_hash.each do |month, month_hash|
price = month_hash['Minsk']
next unless price

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

def find_min_year(year, min_month_data, min_year_price)
result = {}
min_month_price = min_month_data["price"]
result['month'] = min_month_data["month"]

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.


def find_min_year(year, min_month_data, min_year_price)
result = {}
min_month_price = min_month_data["price"]

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.

def find_min_month(year_hash, min_month_price = 9_999_999_999_999, min_month = nil)
year_hash.each do |month, month_hash|
price = month_hash['Minsk']
next unless price

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

if product_data[current_month]
month_key = current_month
else
month_key = product_data.keys.max{ |a,b| month_map[a].to_i <=> month_map[b].to_i }

Choose a reason for hiding this comment

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

Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceAfterComma: Space missing after comma.

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.

file_instance = get_file_instance(file_path)
fetch_products_data(file_instance, products, regions) if file_instance
end
loop do

Choose a reason for hiding this comment

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

Metrics/BlockLength: Block has too many lines. [27/25]

file_paths = Dir['./data/*']
file_paths.each do |file_path|
file_instance = get_file_instance(file_path)
fetch_products_data(file_instance, products, regions) if file_instance

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

year = data['year']
month = data['month']
origin_product = data['product']
return form_similar_products_array(products, price, year, month, origin_product)

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.

end

def get_closest_month(current_month, product_data, month_map)
if product_data[current_month]

Choose a reason for hiding this comment

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

Style/ConditionalAssignment: Use the return of the conditional for variable assignment and comparison.

if product_data[current_year]
year_key = current_year
else
year_key = product_data.keys.max { |a, b| a.to_i <=> b.to_i }

Choose a reason for hiding this comment

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

Performance/CompareWithBlock: Use max_by(&:to_i) instead of max { |a, b| a.to_i <=> b.to_i }.

ext = file_path.split('.')[2]
file_instance = nil
if ext == 'xls' || ext == 'xlsx'
file_instance = Roo::Spreadsheet.open(file_path)

Choose a reason for hiding this comment

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

Lint/UselessAssignment: Useless assignment to variable - file_instance.

if /http:\/\/www.belstat.gov.by/ === str_link
f_link = str_link
else
f_link = 'http://www.belstat.gov.by' + str_link

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.

str_link = URI.unescape(str_link)
str_link = URI.escape(str_link)
if /http:\/\/www.belstat.gov.by/ === str_link
f_link = str_link

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.

str_link = link.href.to_s
str_link = URI.unescape(str_link)
str_link = URI.escape(str_link)
if /http:\/\/www.belstat.gov.by/ === str_link

Choose a reason for hiding this comment

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

Style/ConditionalAssignment: Use the return of the conditional for variable assignment and comparison.
Performance/RegexpMatch: Use match? instead of === when MatchData is not used.
Style/RegexpLiteral: Use %r around regular expression.
Style/CaseEquality: Avoid the use of the case equality operator ===.

page.links_with(:href => /.xls/).each do |link|
str_link = link.href.to_s
str_link = URI.unescape(str_link)
str_link = URI.escape(str_link)

Choose a reason for hiding this comment

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

Lint/UriEscapeUnescape: URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.

7
fix7
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.

if product_data[current_month]
return month_key = current_month
else
return month_key = product_data.keys.max { |a, b| month_map[a].to_i <=> month_map[b].to_i }

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.
Lint/UselessAssignment: Useless assignment to variable - month_key.


def get_closest_month(current_month, product_data, month_map)
if product_data[current_month]
return month_key = current_month

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.
Lint/UselessAssignment: Useless assignment to variable - month_key.

end

def get_closest_month(current_month, product_data, month_map)
if product_data[current_month]

Choose a reason for hiding this comment

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

Style/GuardClause: Use a guard clause instead of wrapping the code inside a conditional expression.

if product_data[current_year]
return year_key = current_year
else
return year_key = product_data.keys.max { |a, b| a.to_i <=> b.to_i }

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.
Lint/UselessAssignment: Useless assignment to variable - year_key.
Performance/CompareWithBlock: Use max_by(&:to_i) instead of max { |a, b| a.to_i <=> b.to_i }.


def get_closest_year(current_year, product_data)
if product_data[current_year]
return year_key = current_year

Choose a reason for hiding this comment

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

Style/RedundantReturn: Redundant return detected.
Lint/UselessAssignment: Useless assignment to variable - year_key.

product_month_data = product_year_data[year_key]
month_key = get_closest_month(current_month, product_month_data, month_map)
return { 'price' => product_month_data[month_key]['Minsk'], 'year' => year_key,
'month' => month_key, 'product' => key }

Choose a reason for hiding this comment

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

Layout/AlignHash: Align the elements of a hash literal if they span more than one line.
Layout/TrailingWhitespace: Trailing whitespace detected.

str_link
else
'http://www.belstat.gov.by' + str_link
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 16, 2 is not aligned with if at 12, 11.

str_link = WEBrick::HTTPUtils.escape(str_link)
f_link = if %r{http:\/\/www.belstat.gov.by}.match?(str_link)
str_link
else

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.

str_link = WEBrick::HTTPUtils.unescape(str_link)
str_link = WEBrick::HTTPUtils.escape(str_link)
f_link = if %r{http:\/\/www.belstat.gov.by}.match?(str_link)
str_link

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not -7) spaces for indentation.


agent = Mechanize.new
page = agent.get('http://www.belstat.gov.by/ofitsialnaya-statistika/makroekonomika-i-okruzhayushchaya-sreda/tseny/operativnaya-informatsiya_4/srednie-tseny-na-potrebitelskie-tovary-i-uslugi-po-respublike-belarus')
page.links_with(:href => /.xls/).each do |link|

Choose a reason for hiding this comment

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

Style/HashSyntax: Use the new Ruby 1.9 hash syntax.

8
fix
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.

end

def form_recent_price_data(price, year, month, product)
{

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

end
end

def get_recent_price_data(key, products, month_map)

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for get_recent_price_data is too high. [15.68/15]

9
fix
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.

end

def parse_month(month_map)
month_map.each { |month, month_number| current_month = month if month_number == current_month }

Choose a reason for hiding this comment

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

Lint/UselessAssignment: Useless assignment to variable - current_month.


def get_recent_price_data(key, products, month_map)
current_year = Time.now.strftime('%Y').to_s
current_month = Time.now.strftime('%m')

Choose a reason for hiding this comment

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

Lint/UselessAssignment: Useless assignment to variable - current_month.

fix
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.

def get_recent_price_data(key, products, month_map)
current_year = Time.now.strftime('%Y').to_s
current_month = parse_month(month_map)
product_year_data = products[key];

Choose a reason for hiding this comment

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

Style/Semicolon: Do not use semicolons to terminate expressions.

fix
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.

fix
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.

str_link = link.href.to_s
str_link = WEBrick::HTTPUtils.unescape(str_link)
str_link = WEBrick::HTTPUtils.escape(str_link)
f_link = if %r{http:\/\/www.belstat.gov.by}.match?(str_link)
Copy link
Collaborator

Choose a reason for hiding this comment

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

можно проще) str_link.start_with?('/')

Copy link
Author

Choose a reason for hiding this comment

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

Заменил

file_instance = nil
if ext == 'xls' || ext == 'xlsx'
Roo::Spreadsheet.open(file_path)
file_instance = conditiona_load(ext, file_path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Очепятки

Copy link
Author

Choose a reason for hiding this comment

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

Исправлено

ext = file_path.split('.')[2]
file_instance = nil
if ext == 'xls' || ext == 'xlsx'
Roo::Spreadsheet.open(file_path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

бесполезная строка

Copy link
Author

Choose a reason for hiding this comment

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

Удалено


def find_keys(word, products)
result = []
products.keys.each { |key|
Copy link
Collaborator

Choose a reason for hiding this comment

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

можно использовать select, и обойтись без объявления result

Copy link
Author

Choose a reason for hiding this comment

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

Сделано

end

def fetch_products_data(file_instance, products, regions)
for n in 9..file_instance.last_row
Copy link
Collaborator

Choose a reason for hiding this comment

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

Enumerable.drop(9), iterate over rows.

Copy link
Author

Choose a reason for hiding this comment

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

Заменил на (9..file_instance.last_row).each do |n|

end
end

def add_product(products, key, year, month, regions, file_instance, n)
Copy link
Collaborator

Choose a reason for hiding this comment

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

вынеси парсинг в отдельный метод

Copy link
Author

Choose a reason for hiding this comment

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

Сделано

end

def get_min_price(hash)
min_year_price = 9_999_999_999_999
Copy link
Collaborator

Choose a reason for hiding this comment

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

Нельзя так делать. Ты недооцениваешь грядущую инфляцию белорусского рубля)
Есть Float::INFINITY, но лучше вычислить минимум вызовом .min на масиве с нужными данными

Copy link
Author

Choose a reason for hiding this comment

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

Заменил на Float::INFINITY

'ноябрь' => 11,
'декабрь' => 12
}
regions = ['Brest', 'Vitebsk', 'Gomel', 'Grodno', 'Minsk', 'Minsk Region', 'Mogilyov']
Copy link
Collaborator

Choose a reason for hiding this comment

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

оберни весь исполняемый код в медот main

Copy link
Author

Choose a reason for hiding this comment

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

Сделано

Hryvicki Kirill/0/run.rb Show resolved Hide resolved
@RGBD RGBD self-assigned this Dec 9, 2018
fix
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.

result
end

def main()

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for main is too high. [63.04/15]
Metrics/MethodLength: Method has too many lines. [48/10]
Style/DefWithParentheses: Omit the parentheses in defs when the method doesn't accept any arguments.

fix
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.

loop do
puts 'What price are you looking for?'
word = gets.chomp.downcase.encode('UTF-8')
keys = $products.keys.select { |key| key.include?(word) }

Choose a reason for hiding this comment

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

Style/GlobalVars: Do not introduce global variables.

end
end

def main

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for main is too high. [20.25/15]
Metrics/MethodLength: Method has too many lines. [17/10]


def second_level_max_price(key)
max_price = get_max_price($products[key])
puts 'Maximum was on ' + max_price['year'] + '/' + $month_map[max_price['month']].to_s + ' at price '

Choose a reason for hiding this comment

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

Style/GlobalVars: Do not introduce global variables.

end

def second_level_max_price(key)
max_price = get_max_price($products[key])

Choose a reason for hiding this comment

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

Style/GlobalVars: Do not introduce global variables.

print min_price['price'].to_s + ' BYN'
end

def second_level_max_price(key)

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for second_level_max_price is too high. [15.03/15]

result
end

def init_variables

Choose a reason for hiding this comment

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

Metrics/MethodLength: Method has too many lines. [21/10]


def form_similar_products_array( price, year, month, origin_product)
result = []
$products.each do |product, product_data|

Choose a reason for hiding this comment

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

Style/GlobalVars: Do not introduce global variables.

form_similar_products_array( price, year, month, origin_product)
end

def form_similar_products_array( price, year, month, origin_product)

Choose a reason for hiding this comment

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

Layout/SpaceInsideParens: Space inside parentheses detected.

year = data['year']
month = data['month']
origin_product = data['product']
form_similar_products_array( price, year, month, origin_product)

Choose a reason for hiding this comment

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

Layout/SpaceInsideParens: Space inside parentheses detected.


def get_closest_month(current_month, product_data)
current_month if product_data[current_month]
product_data.keys.max { |a, b| $month_map[a].to_i <=> $month_map[b].to_i } unless product_data[current_month]

Choose a reason for hiding this comment

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

Style/GlobalVars: Do not introduce global variables.

fix
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.

Hryvicki Kirill/0/run.rb Show resolved Hide resolved
fix
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.

source "https://rubygems.org"

gem 'mechanize'
gem 'roo'

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

@@ -0,0 +1,5 @@
source "https://rubygems.org"

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.

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.

Hryvicki Kirill/0/run.rb Show resolved Hide resolved
products = make_products_container
loop do
keys = user_wish(products)
puts word.capitalize + ' can not be found in database' if keys.empty?
Copy link
Collaborator

Choose a reason for hiding this comment

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

дважды проверяется одно условие. лучше так

if keys.empty?
  puts ...
  next
end
...

products.keys.select { |key| key.include?(word) }
end

def month_map_former
Copy link
Collaborator

Choose a reason for hiding this comment

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

не нужен метод, можно обойтись константой

end

def first_level(key, recent_price_data)
puts ''
Copy link
Collaborator

Choose a reason for hiding this comment

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

just

puts


def form_similar_products_array(products, price, year, month, origin_product)
result = []
products.each do |product, product_data|
Copy link
Collaborator

Choose a reason for hiding this comment

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

products.select
и не понадобится result

result
end

def find_max_month(year_hash, max_month_price = 0, max_month = nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

последние два параметра не нужны, объяви переменные в методе
а лучше используй select, max_by

end

def find_min_month(year_hash, min_month_price = Float::INFINITY, min_month = nil)
year_hash.each do |month, month_hash|
Copy link
Collaborator

Choose a reason for hiding this comment

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

параметры не нужны, объяви переменные внутри метода

end

def get_closest_month(current_month, product_data, month_map)
current_month if product_data[current_month]
Copy link
Collaborator

Choose a reason for hiding this comment

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

если не имелось в виду return current_month if то строка бесполезна

end

def get_closest_year(current_year, product_data)
current_year if product_data[current_year]
Copy link
Collaborator

Choose a reason for hiding this comment

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

строка бесполезна


def parse_month(month_map)
current_month = Time.now.strftime('%m')
month_map.each { |month, month_number| current_month = month if month_number == current_month }
Copy link
Collaborator

Choose a reason for hiding this comment

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

==

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