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

Ivan Shishkov #21

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

Ivan Shishkov #21

wants to merge 13 commits into from

Conversation

Ivsh312
Copy link

@Ivsh312 Ivsh312 commented Dec 8, 2018

Name

Shishkov Ivan

Homework#

0

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.

}
return result
end
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.

result['price'] = maxYearPrice;
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(maxMonthPrice > maxYearPrice)
maxYearPrice = maxMonthPrice;
result['year'] = year;
result['price'] = maxYearPrice;

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.

}
if(maxMonthPrice > maxYearPrice)
maxYearPrice = maxMonthPrice;
result['year'] = year;

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.

end
}
if(maxMonthPrice > maxYearPrice)
maxYearPrice = maxMonthPrice;

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.
Style/Semicolon: Do not use semicolons to terminate expressions.

result = Hash.new;
maxYearPrice = 0;

hash.each{|year, yearHash|

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/SpaceInsideBlockBraces: Space between { and | missing.
Style/BlockDelimiters: Avoid using {...} for multi-line blocks.
Naming/UncommunicativeBlockParamName: Only use lowercase characters for block parameter.
Naming/VariableName: Use snake_case for variable names.


def getMaxPrice(hash)
result = Hash.new;
maxYearPrice = 0;

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.
Style/Semicolon: Do not use semicolons to terminate expressions.

end

def getMaxPrice(hash)
result = Hash.new;

Choose a reason for hiding this comment

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

Style/EmptyLiteral: Use hash literal {} instead of Hash.new.
Style/Semicolon: Do not use semicolons to terminate expressions.

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. [18/10]
Naming/MethodName: Use snake_case for method names.

result['price'] = minYearPrice;
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.

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
}
if(min_Month_Price < min_Year_Price)
min_Year_Price = min_Month_Price

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.

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.

Layout/SpaceAroundKeyword: Space after keyword if is missing.
Style/Next: Use next to skip iteration.

min_Month_Price = price
result['month'] = month
end
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.

price = month_Hash['Minsk']
if price
if(price < min_Month_Price)
min_Month_Price = price

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.

year_Hash.each{|month, month_Hash|
price = month_Hash['Minsk']
if price
if(price < min_Month_Price)

Choose a reason for hiding this comment

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

Layout/SpaceAroundKeyword: Space after keyword if is missing.

}
end

def get_Min_Price(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. [20/10]
Naming/MethodName: Use snake_case for method names.

return {
"price" => product_Month_Data[monthKey]["Minsk"],
"year" => yearKey,
"month" => monthKey

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.


return {
"price" => product_Month_Data[monthKey]["Minsk"],
"year" => yearKey,

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

return {
"price" => product_Month_Data[monthKey]["Minsk"],

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.

monthKey = product_Month_Data.keys.max{|a,b| months[a] <=> months[b]}
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.

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(min_Month_Price < min_Year_Price)
min_Year_Price = min_Month_Price
result['year'] = year
result['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/Semicolon: Do not use semicolons to terminate expressions.

}
if(min_Month_Price < min_Year_Price)
min_Year_Price = min_Month_Price
result['year'] = year

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.

end
}
if(min_Month_Price < min_Year_Price)
min_Year_Price = min_Month_Price

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.
Style/Semicolon: Do not use semicolons to terminate expressions.

if(price < min_Month_Price)
min_Month_Price = price
result['month'] = month
end

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.

if price
if(price < min_Month_Price)
min_Month_Price = price
result['month'] = month

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.

}
end

def get_Min_Price(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. [18/10]
Naming/MethodName: Use snake_case for method names.

if product_Month_Data[current_Month]
monthKey = current_Month
else
monthKey = product_Month_Data.keys.max{|a,b| months[a] <=> months[b]}

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.
Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceInsideBlockBraces: Space between { and | missing.
Layout/SpaceAfterComma: Space missing after comma.
Layout/SpaceInsideBlockBraces: Space missing inside }.

product_Month_Data = product_Year_Data[yearKey]

if product_Month_Data[current_Month]
monthKey = current_Month

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.
Style/Semicolon: Do not use semicolons to terminate expressions.


product_Month_Data = product_Year_Data[yearKey]

if product_Month_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.

yearKey = product_Year_Data.keys.max{|a,b| a.to_i <=> b.to_i}
end

product_Month_Data = product_Year_Data[yearKey]

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.
Style/Semicolon: Do not use semicolons to terminate expressions.

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 get_Max_Price(hash)

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.

end
end

def get_Min_Price(hash)

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.

result = val.to_f

if year.to_i < 2017
result = result / 10000

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.

if val
result = val.to_f

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/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.

end

def format_Value(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.

def find_Keys(word, products)
keys = []
products.keys.each{ |key|
if(key.include?(word))

Choose a reason for hiding this comment

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

Layout/SpaceAroundKeyword: Space after keyword if is missing.
Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.


def find_Keys(word, products)
keys = []
products.keys.each{ |key|

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 {.
Style/BlockDelimiters: Avoid using {...} for multi-line blocks.

file;
end

def find_Keys(word, products)

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.

else
puts 'unsupported file type: ' + file_Path
end
file;

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.

{"price" => product_Month_Data[month_Key]["Minsk"], "year" => year_Key, "month" => month_Key }
end

def get_File(file_Path)

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.
Naming/UncommunicativeMethodParamName: Only use lowercase characters for method parameter.
Naming/VariableName: Use snake_case for variable names.

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.

regions[3] => format_Value(file.cell('M', index), year),
regions[4] => format_Value(file.cell('O', index), year),
regions[5] => format_Value(file.cell('Q', index), year),
regions[6] => format_Value(file.cell('S', index), year)}

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.
Performance/CompareWithBlock: Use max_by(&:to_i) instead of max { |a, b| a.to_i <=> b.to_i }.
Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceInsideBlockBraces: Space between { and | missing.
Layout/SpaceAfterComma: Space missing after comma.
Layout/SpaceInsideBlockBraces: Space missing inside }.

regions[1] => format_Value(file.cell('I', index), year),
regions[2] => format_Value(file.cell('K', index), year),
regions[3] => format_Value(file.cell('M', index), year),
regions[4] => format_Value(file.cell('O', index), year),

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.

regions[0] => format_Value(file.cell('G', index), year),
regions[1] => format_Value(file.cell('I', index), year),
regions[2] => format_Value(file.cell('K', index), year),
regions[3] => format_Value(file.cell('M', index), year),

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.

products[key][year] = {} unless products[key][year]
products[key][year][month] = {
regions[0] => format_Value(file.cell('G', index), year),
regions[1] => format_Value(file.cell('I', index), year),

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.

end
end

def add_Products(products, year, month, key, regions, file, index)

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 &&/||.

Shishkov_Ivan/0/WorkWithData.rb Outdated Show resolved Hide resolved
def find_Keys(word, products)
keys = []
products.keys.each{ |key|
if(key.include?(word))

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.


def find_Keys(word, products)
keys = []
products.keys.each{ |key|

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.

else
puts 'unsupported file type: ' + file_Path
end
file;

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.

file = Roo::Excelx.new(file_Path)
else
puts 'unsupported file type: ' + file_Path
end

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.

@RGBD RGBD added the invalid This doesn't seem right label 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.

Переназови PR

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.

regions[4] => format_value(file.cell('O', index), year),
regions[5] => format_value(file.cell('Q', index), year),
regions[6] => format_value(file.cell('S', index), year)
}

Choose a reason for hiding this comment

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

Layout/IndentHash: Indent the right brace the same as the start of the line where the left brace is.

regions[3] => format_value(file.cell('M', index), year),
regions[4] => format_value(file.cell('O', index), year),
regions[5] => format_value(file.cell('Q', index), year),
regions[6] => format_value(file.cell('S', index), year)

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 add_products(products, year, month, key, regions, file, index)
products[key] = {} unless products[key]
products[key][year] = {} unless products[key][year]
products[key][year][month] = {

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 add_products(products, year, month, key, regions, file, index)

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 add_products is too high. [27.24/15]
Metrics/MethodLength: Method has too many lines. [11/10]
Metrics/ParameterLists: Avoid parameter lists longer than 5 parameters. [7/5]

def find_keys(word, products)
keys = []
products.keys.each do |key|
keys.push(key) if (key.include?(word))

Choose a reason for hiding this comment

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

Style/ParenthesesAroundCondition: Don't use parentheses around the condition of an if.
Style/RedundantParentheses: Don't use parentheses around a method call.


def get_month_key(product_month_data, current_months, month_Map)
if product_month_data[current_months]
return current_months

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_month_key(product_month_data, current_months, month_Map)
if product_month_data[current_months]

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 get_month_key(product_month_data, current_months, month_Map)

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Only use lowercase characters for method parameter.
Naming/VariableName: Use snake_case for variable names.

if product_year_data[@current_year]
return @current_year
else
return product_year_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.
Performance/CompareWithBlock: Use max_by(&:to_i) instead of max { |a, b| a.to_i <=> b.to_i }.
Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceInsideBlockBraces: Space between { and | missing.
Layout/SpaceAfterComma: Space missing after comma.
Layout/SpaceInsideBlockBraces: Space missing inside }.


def get_year_key(products, key, product_year_data)
if product_year_data[@current_year]
return @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.

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

result.round(2)
end

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.

result = result / 10000
end

result.round(2)

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 &&/||.

result = val.to_f

if year.to_i < 2017
result = result / 10000

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.

year = file.cell('A', 3).split(' ')[2]
month = file.cell('A', 3).split(' ')[1]
key = file.cell('A', index).strip.downcase
add_products(products, year, month, key, regions, file, index)

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.

year_Key = get_year_key(products, key, product_year_data)
product_month_data = product_year_data[year_Key]
month_key = get_month_key(product_month_data, current_months, month_Map)
{'price' => product_month_data[month_key]['Minsk'], 'year' => year_Key, 'month' => month_key }

Choose a reason for hiding this comment

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

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end
end

def get_month_key(product_month_data, current_months, month_Map)

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.
Naming/UncommunicativeMethodParamName: Only use lowercase characters for method parameter.
Naming/VariableName: Use snake_case for variable names.

end

def get_year_key(products, key, product_year_data)
if product_year_data[@current_year]

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.

current_months
end

def get_year_key(products, key, product_year_data)

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.
Lint/UnusedMethodArgument: Unused method argument - products. If it's necessary, use _ or _products as an argument name to indicate that it won't be used.
Lint/UnusedMethodArgument: Unused method argument - key. If it's necessary, use _ or _key as an argument name to indicate that it won't be used.
Naming/UncommunicativeMethodParamName: Only use lowercase characters for method parameter.
Naming/VariableName: Use snake_case for variable names.

def get_mount(month, monthNumber)
current_months = @current_month
if monthNumber == @current_month
return current_months = month

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.


def get_mount(month, monthNumber)
current_months = @current_month
if monthNumber == @current_month

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 &&/||.

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.

Please, use_snake_case.
this_Is_Not_Snake_Case!


require "roo-xls"

require "./WorkWithData.rb"
Copy link
Collaborator

Choose a reason for hiding this comment

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

use snake case for file naming

require "./WorkWithData.rb"

funcs = FilesParse.new
months = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make Constant

'декабрь' => 12,
}

regions = ['Brest',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make Constant

'Minsk',
'Grodno Region',
'Mogilyov']
products = Hash.new
Copy link
Collaborator

Choose a reason for hiding this comment

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

{}

'Grodno Region',
'Mogilyov']
products = Hash.new
file_Paths = Dir['./data/*']
Copy link
Collaborator

Choose a reason for hiding this comment

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

use_snake_case

file = funcs.get_File(file_Path)

if file
funcs.fetch_Products_Data(file, products, regions)
Copy link
Collaborator

Choose a reason for hiding this comment

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

use_snake_case

@@ -0,0 +1,182 @@
class FilesParse

attr_accessor :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.

remove extra spaces

extention = file_Path.split('.')[2]
case extention
when 'xls'
file = Roo::Excel.new(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.

You can use Roo::Spreadsheet, it reads both xls and xlsx

@Ivsh312 Ivsh312 changed the title Shishkov Ivan Ivan Shishkov Dec 9, 2018
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 year.to_i < 2017
result = result / 10000
end

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.

result = val.to_f

if year.to_i < 2017
result = result / 10000

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 &&/||.


def format_value(val, year)
if val
result = val.to_f

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

def add_products(products, year, month, key, regions, file, index)
products[key] = {} unless products[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 add_products is too high. [27.24/15]
Metrics/MethodLength: Method has too many lines. [11/10]
Metrics/ParameterLists: Avoid parameter lists longer than 5 parameters. [7/5]


def fetch_products_data(file, products, regions)
for index in 9..file.last_row
next if file.cell('E', index).nil?

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.

def get_month_key(product_month_data, current_months, month_Map)
if product_month_data[current_months]
return current_months
else

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 get_month_key(product_month_data, current_months, month_Map)
if product_month_data[current_months]
return current_months

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

def get_month_key(product_month_data, current_months, month_Map)
if product_month_data[current_months]

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Only use lowercase characters for method parameter.
Naming/VariableName: Use snake_case for variable names.

return @current_year
else
return product_year_data.keys.max{|a,b| a.to_i <=> b.to_i}
end

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.
Performance/CompareWithBlock: Use max_by(&:to_i) instead of max { |a, b| a.to_i <=> b.to_i }.
Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceInsideBlockBraces: Space between { and | missing.
Layout/SpaceAfterComma: Space missing after comma.
Layout/SpaceInsideBlockBraces: Space missing inside }.

def get_year_key(products, key, product_year_data)
if product_year_data[@current_year]
return @current_year
else

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.

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.

@current_year = Time.now.strftime('%Y').to_s
end

def get_mount(month, monthNumber)

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Only use lowercase characters for method parameter.
Naming/VariableName: Use snake_case for variable names.

@@ -0,0 +1,177 @@
class FilesParse

Choose a reason for hiding this comment

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

Layout/EndOfLine: Carriage return character detected.
Metrics/ClassLength: Class has too many lines. [157/100]

max_price = funcs.get_max_price(products[key])
puts 'Maximum was on ' + max_price['year'] +
'/' + months[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.

' at price ' + min_Price['price'].to_s + ' BYN'
max_price = funcs.get_max_price(products[key])
puts 'Maximum was on ' + max_price['year'] +
'/' + months[max_price['month']].to_s +

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 = funcs.get_min_price(products[key])
puts 'Lowest was on ' + min_Price['year'] +
'/' + months[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.

products = {}
file_paths = Dir['./data/*']

file_paths.each{ |file_path|

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 {.
Style/BlockDelimiters: Avoid using {...} for multi-line blocks.

'Grodno Region',
'Mogilyov']
products = {}
file_paths = Dir['./data/*']

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Operator = should be surrounded by a single space.
Layout/ExtraSpacing: Unnecessary spacing detected.

'Grodno',
'Minsk',
'Grodno Region',
'Mogilyov']

Choose a reason for hiding this comment

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

Layout/AlignArray: Align the elements of an array literal if they span more than one line.

'Gomel',
'Grodno',
'Minsk',
'Grodno Region',

Choose a reason for hiding this comment

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

Layout/AlignArray: Align the elements of an array literal if they span more than one line.

'Vitebsk',
'Gomel',
'Grodno',
'Minsk',

Choose a reason for hiding this comment

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

Layout/AlignArray: Align the elements of an array literal if they span more than one line.
Layout/TrailingWhitespace: Trailing whitespace detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants