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

Use most recent rubocop rules #589

Merged
merged 4 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Security/YAMLLoad:
Enabled: false

inherit_from:
- http://s3.amazonaws.com/openstudio-resources/styles/rubocop.yml
- http://s3.amazonaws.com/openstudio-resources/styles/rubocop_v3.yml
- http://s3.amazonaws.com/openstudio-resources/styles/rubocop-rails.yml
2 changes: 1 addition & 1 deletion ci/travis/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ else

# set the ulimit to be higher
ulimit -a
ulimit -n 2048
ulimit -n 4096
ulimit -a

elif [ "${TRAVIS_OS_NAME}" == "linux" ]; then
Expand Down
14 changes: 7 additions & 7 deletions server/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ gem 'sprockets-rails'
gem 'uglifier'

# don't try to install sassc 2.
gem 'sassc', '~>1.12.1'
gem 'roo', '~>2.8.3'
gem 'sassc', '~>1.12.1'

# For workers - and other dependencies for measures
## Commonly update gems for testing and development
Expand All @@ -70,13 +70,13 @@ gem 'openstudio-analysis', '= 1.0.4'

gem 'openstudio-aws', '0.7.1'

#libxml 3.2.0 failing on windows
# libxml 3.2.0 failing on windows
gem 'bson', '4.5.0' # bson 4.6.0 requires ruby >= 2.3.0
gem 'libxml-ruby', '3.1.0'
gem 'msgpack', '~> 1.0'
gem 'multi_json'
gem 'rest-client', '~>2.0.1'
gem 'nio4r', '~>2.3.1' # 2.4.0 breaks w/ruby 2.2.4
gem 'bson', '4.5.0' # bson 4.6.0 requires ruby >= 2.3.0
gem 'rest-client', '~>2.0.1'

# add to Gemfile to make available to Ruby scripts running via initialize/finalize scripts
gem 'rubyXL', '~> 3.3.29'
Expand All @@ -90,8 +90,8 @@ end

# The only resque only is :docker, :docker-dev, :production
group :development, :docker, :'docker-dev', :'docker-test', :production, :test do
gem 'redis', '=4.1.0'
gem 'redis-namespace', '=1.6.0'
gem 'redis', '=4.1.0'
gem 'resque', '=1.27.4'
gem 'resque-web', require: 'resque_web'
end
Expand All @@ -105,9 +105,9 @@ group :development, :test do
gem 'meta_request'

gem 'capybara'
gem 'puma' #used by capybara
gem 'public_suffix', '=3.0.3'
gem 'coveralls', require: false
gem 'public_suffix', '=3.0.3'
gem 'puma' # used by capybara
gem 'rspec', '~> 3.4'
gem 'rspec-rails'
gem 'rspec-retry'
Expand Down
4 changes: 2 additions & 2 deletions server/app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def index
@gems = Gem::Specification.all.map { |g| [g.name, g.version.to_s] }.sort
Rails.logger.debug "oscli version command: #{Utility::Oss.oscli_cmd} openstudio_version"
# syntax to explicitly unset a bunch of env vars is very different for windows
unset_vars = (Gem.win_platform? || ENV['OS'] == 'Windows_NT') ? 'set '+ Utility::Oss::ENV_VARS_TO_UNSET_FOR_OSCLI.join('= && set '): 'unset '+Utility::Oss::ENV_VARS_TO_UNSET_FOR_OSCLI.join(' && unset ')
unset_vars = Gem.win_platform? || ENV['OS'] == 'Windows_NT' ? 'set ' + Utility::Oss::ENV_VARS_TO_UNSET_FOR_OSCLI.join('= && set ') : 'unset ' + Utility::Oss::ENV_VARS_TO_UNSET_FOR_OSCLI.join(' && unset ')
oscli_cmd = "#{Utility::Oss.oscli_cmd} openstudio_version"
oscli_cmd = "call #{oscli_cmd}" if (Gem.win_platform? || ENV['OS'] == 'Windows_NT')
oscli_cmd = "call #{oscli_cmd}" if Gem.win_platform? || ENV['OS'] == 'Windows_NT'
version = `#{unset_vars} && #{oscli_cmd}`
Rails.logger.debug "oscli version output: #{version}"
@os_cli = version ? version.strip : 'Unknown'
Expand Down
90 changes: 42 additions & 48 deletions server/app/controllers/analyses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def download_result_file
@analysis = Analysis.find(params[:id])

file = @analysis.result_files.where(attachment_file_name: params[:filename]).first
if file && file.attachment && File.exist?(file.attachment.path)
if file&.attachment && File.exist?(file.attachment.path)
file_data = File.read(file.attachment.path)
disposition = ['application/json', 'text/plain', 'text/html'].include?(file.attachment.content_type) ? 'inline' : 'attachment'
send_data file_data, filename: File.basename(file.attachment.original_filename), type: file.attachment.content_type, disposition: disposition
Expand Down Expand Up @@ -780,54 +780,48 @@ def dencity
@provenance['analysis_information'] = @analysis['problem']['algorithm']
end

if @analysis['problem']['workflow']
@analysis['problem']['workflow'].each do |wf|
new_wfi = {}
new_wfi['id'] = wf['measure_definition_uuid']
new_wfi['version_id'] = wf['measure_definition_version_uuid']

# Eventually all of this could be pulled directly from BCL
new_wfi['name'] = wf['measure_definition_class_name']
new_wfi['display_name'] = wf['measure_definition_display_name']
new_wfi['type'] = wf['measure_type']
new_wfi['modeler_description'] = wf['modeler_description']
new_wfi['description'] = wf['description']

new_wfi['arguments'] = []
if wf['arguments']
wf['arguments'].each do |arg|
wfi_arg = {}
wfi_arg['display_name'] = arg['display_name']
wfi_arg['display_name_short'] = arg['display_name_short']
wfi_arg['name'] = arg['name']
wfi_arg['data_type'] = arg['value_type']
wfi_arg['default_value'] = nil
wfi_arg['description'] = ''
wfi_arg['display_units'] = '' # should be haystack compatible unit strings
wfi_arg['units'] = '' # should be haystack compatible unit strings

new_wfi['arguments'] << wfi_arg
end
end

if wf['variables']
wf['variables'].each do |arg|
wfi_var = {}
wfi_var['display_name'] = arg['argument']['display_name']
wfi_var['display_name_short'] = arg['argument']['display_name_short']
wfi_var['name'] = arg['argument']['name']
wfi_var['default_value'] = nil
wfi_var['data_type'] = arg['argument']['value_type']
wfi_var['description'] = ''
wfi_var['display_units'] = arg['units']
wfi_var['units'] = '' # should be haystack compatible unit strings

new_wfi['arguments'] << wfi_var
end
end

@measure_metadata << new_wfi
@analysis['problem']['workflow']&.each do |wf|
new_wfi = {}
new_wfi['id'] = wf['measure_definition_uuid']
new_wfi['version_id'] = wf['measure_definition_version_uuid']

# Eventually all of this could be pulled directly from BCL
new_wfi['name'] = wf['measure_definition_class_name']
new_wfi['display_name'] = wf['measure_definition_display_name']
new_wfi['type'] = wf['measure_type']
new_wfi['modeler_description'] = wf['modeler_description']
new_wfi['description'] = wf['description']

new_wfi['arguments'] = []
wf['arguments']&.each do |arg|
wfi_arg = {}
wfi_arg['display_name'] = arg['display_name']
wfi_arg['display_name_short'] = arg['display_name_short']
wfi_arg['name'] = arg['name']
wfi_arg['data_type'] = arg['value_type']
wfi_arg['default_value'] = nil
wfi_arg['description'] = ''
wfi_arg['display_units'] = '' # should be haystack compatible unit strings
wfi_arg['units'] = '' # should be haystack compatible unit strings

new_wfi['arguments'] << wfi_arg
end

wf['variables']&.each do |arg|
wfi_var = {}
wfi_var['display_name'] = arg['argument']['display_name']
wfi_var['display_name_short'] = arg['argument']['display_name_short']
wfi_var['name'] = arg['argument']['name']
wfi_var['default_value'] = nil
wfi_var['data_type'] = arg['argument']['value_type']
wfi_var['description'] = ''
wfi_var['display_units'] = arg['units']
wfi_var['units'] = '' # should be haystack compatible unit strings

new_wfi['arguments'] << wfi_var
end

@measure_metadata << new_wfi
end
end
end
Expand Down
38 changes: 17 additions & 21 deletions server/app/controllers/data_points_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def download_report
h = @data_point.result_files.where(display_name: dp_params[:filename]).first
end

if h && h.attachment && File.exist?(h.attachment.path)
if h&.attachment && File.exist?(h.attachment.path)
if /darwin/.match(RUBY_PLATFORM) || /linux/.match(RUBY_PLATFORM)
file_data = File.read(h.attachment.path)
else
Expand All @@ -374,7 +374,7 @@ def download_result_file
@data_point = DataPoint.find(params[:id])

file = @data_point.result_files.where(attachment_file_name: params[:filename]).first
if file && file.attachment && File.exist?(file.attachment.path)
if file&.attachment && File.exist?(file.attachment.path)
if /darwin/.match(RUBY_PLATFORM) || /linux/.match(RUBY_PLATFORM)
file_data = File.read(file.attachment.path)
else
Expand All @@ -401,28 +401,24 @@ def dencity
# instructions for building the inputs
measure_instances = []
if @data_point.analysis['problem']
if @data_point.analysis['problem']['workflow']
@data_point.analysis['problem']['workflow'].each_with_index do |wf, _index|
m_instance = {}
m_instance['uri'] = 'https://bcl.nrel.gov or file:///local'
m_instance['id'] = wf['measure_definition_uuid']
m_instance['version_id'] = wf['measure_definition_version_uuid']

if wf['arguments']
m_instance['arguments'] = {}
if wf['variables']
wf['variables'].each do |var|
m_instance['arguments'][var['argument']['name']] = @data_point.set_variable_values[var['uuid']]
end
end

wf['arguments'].each do |arg|
m_instance['arguments'][arg['name']] = arg['value']
end
@data_point.analysis['problem']['workflow']&.each_with_index do |wf, _index|
m_instance = {}
m_instance['uri'] = 'https://bcl.nrel.gov or file:///local'
m_instance['id'] = wf['measure_definition_uuid']
m_instance['version_id'] = wf['measure_definition_version_uuid']

if wf['arguments']
m_instance['arguments'] = {}
wf['variables']&.each do |var|
m_instance['arguments'][var['argument']['name']] = @data_point.set_variable_values[var['uuid']]
end

measure_instances << m_instance
wf['arguments'].each do |arg|
m_instance['arguments'][arg['name']] = arg['value']
end
end

measure_instances << m_instance
end
end

Expand Down
Loading