Skip to content

Commit

Permalink
More lint fixes + add rubocop.yml from unity
Browse files Browse the repository at this point in the history
  • Loading branch information
art-of-dom committed Oct 13, 2021
1 parent d8c1fc5 commit ce33f29
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 30 deletions.
76 changes: 76 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This is the configuration used to check the rubocop source code.

#inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.5

# These are areas where ThrowTheSwitch's coding style diverges from the Ruby standard
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names
Style/FormatString:
Enabled: false
Style/GlobalVars:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Style/RegexpLiteral:
AllowInnerSlashes: true
Style/HashSyntax:
EnforcedStyle: no_mixed_keys
Style/NumericPredicate:
Enabled: false
Style/MultilineBlockChain:
Enabled: false
Style/Alias:
Enabled: false
Style/EvalWithLocation:
Enabled: false
Style/MixinUsage:
Enabled: false

# These are also places we diverge... but we will likely comply down the road
Style/IfUnlessModifier:
Enabled: false
Style/FormatStringToken:
Enabled: false

# This is disabled because it seems to get confused over nested hashes
Layout/HashAlignment:
Enabled: false
EnforcedHashRocketStyle: table
EnforcedColonStyle: table

# We purposefully use these insecure features because they're what makes Ruby awesome
Security/Eval:
Enabled: false
Security/YAMLLoad:
Enabled: false

# At this point, we're not ready to enforce inline documentation requirements
Style/Documentation:
Enabled: false
Style/DocumentationMethod:
Enabled: false

# At this point, we're not ready to enforce any metrics
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/BlockNesting:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/LineLength:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
6 changes: 3 additions & 3 deletions bin/ceedling
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ unless (project_found)

puts "WARNING: --no_docs deprecated. It is now the default. Specify -docs if you want docs installed." if (options[:no_docs] || options[:nodocs])
puts "WARNING: --as_gem deprecated. It is now the default. Specify -local if you want ceedling installed to this project." if (options[:as_gem] || options[:asgem])
puts "WARNING: --with_ignore deprecated. It is now called -gitignore" if (options[:with_ignore] || options[:with_ignore])
puts "WARNING: --with_ignore deprecated. It is now called -gitignore" if (options[:with_ignore] || options[:withignore])

use_docs = options[:docs] || false
use_configs = !(options[:no_configs] || options[:noconfigs] || false)
Expand Down Expand Up @@ -269,9 +269,9 @@ else

#guess that we need a special script file first if it exists
if (platform == :mswin)
options[:pretest] = File.exist?("#{ platform.to_s }_setup.bat") ? "#{ platform.to_s }_setup.bat" : nil
options[:pretest] = File.exist?("#{ platform }_setup.bat") ? "#{ platform }_setup.bat" : nil
else
options[:pretest] = File.exist?("#{ platform.to_s }_setup.sh") ? "source #{ platform.to_s }_setup.sh" : nil
options[:pretest] = File.exist?("#{ platform }_setup.sh") ? "source #{ platform }_setup.sh" : nil
end

#merge in project settings if they can be found here
Expand Down
2 changes: 1 addition & 1 deletion lib/ceedling/build_invoker_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def process_exception(exception, context, test_build=true)
@streaminator.stderr_puts( error_header )

if (@configurator.project_use_deep_dependencies)
help_message = "Try fixing #include statements or adding missing file. Then run '#{REFRESH_TASK_ROOT}#{context.to_s}' task and try again."
help_message = "Try fixing #include statements or adding missing file. Then run '#{REFRESH_TASK_ROOT}#{context}' task and try again."
@streaminator.stderr_puts( help_message )
end

Expand Down
4 changes: 2 additions & 2 deletions lib/ceedling/configurator_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def build_global_constants(config)
def build_accessor_methods(config, context)
config.each_pair do |key, value|
# fill configurator object with accessor methods
eval("def #{key.to_s.downcase}() return @project_config_hash[:#{key.to_s}] end", context)
eval("def #{key.to_s.downcase}() return @project_config_hash[:#{key}] end", context)
end
end

Expand Down Expand Up @@ -203,7 +203,7 @@ def expand_all_path_globs(in_hash)

# sorted to provide assured order of traversal in test calls on mocks
path_keys.sort.each do |key|
out_hash["collection_#{key.to_s}".to_sym] = @file_system_utils.collect_paths( in_hash[key] )
out_hash["collection_#{key}".to_sym] = @file_system_utils.collect_paths( in_hash[key] )
end

return out_hash
Expand Down
2 changes: 1 addition & 1 deletion lib/ceedling/configurator_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def retrieve_value(config, keys)

def format_key_sequence(keys, depth)
walked_keys = keys.slice(0, depth)
formatted_keys = walked_keys.map{|key| "[:#{key.to_s}]"}
formatted_keys = walked_keys.map{|key| "[:#{key}]"}

return formatted_keys.join
end
Expand Down
3 changes: 0 additions & 3 deletions lib/ceedling/file_finder.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
require 'rubygems'
require 'rake' # for adding ext() method to string
require 'thread'


class FileFinder
SEMAPHORE = Mutex.new

Expand Down
2 changes: 1 addition & 1 deletion lib/ceedling/flaginator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_flag(hash, file_name)
any, regex = partition(magic) { |k, v| (k == :'*') || (k == :'.*') } # glob or regex wild card

# 2. try regexes
find_res = regex.find { |k, v| file_name =~ /^#{k.to_s}$/ }
find_res = regex.find { |k, v| file_name =~ /^#{k}$/ }
return find_res[1] if find_res

# 3. try anything
Expand Down
10 changes: 5 additions & 5 deletions lib/ceedling/target_loader.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module TargetLoader
class NoTargets < Exception; end
class NoDirectory < Exception; end
class NoDefault < Exception; end
class NoSuchTarget < Exception; end
class NoTargets < RuntimeError; end
class NoDirectory < RuntimeError; end
class NoDefault < RuntimeError; end
class NoSuchTarget < RuntimeError; end

class RequestReload < Exception; end
class RequestReload < RuntimeError; end

def self.inspect(config, target_name=nil)
unless config[:targets]
Expand Down
2 changes: 1 addition & 1 deletion lib/ceedling/tool_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def exec(command, options={}, args=[])
@tool_executor_helper.background_exec_cmdline_append( options ),
].flatten.compact.join(' ')

@streaminator.stderr_puts("Verbose: #{__method__.to_s}(): #{command_line}", Verbosity::DEBUG)
@streaminator.stderr_puts("Verbose: #{__method__}(): #{command_line}", Verbosity::DEBUG)

shell_result = {}

Expand Down
2 changes: 1 addition & 1 deletion plugins/dependencies/lib/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def fetch_if_required(lib_path)
when :custom
blob[:fetch][:executable]
else
raise "Unknown fetch method '#{blob[:fetch][:method].to_s}' for dependency '#{blob[:name]}'"
raise "Unknown fetch method '#{blob[:fetch][:method]}' for dependency '#{blob[:name]}'"
end

# Perform the actual fetching
Expand Down
10 changes: 5 additions & 5 deletions plugins/gcov/gcov.rake
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,18 @@ if PROJECT_USE_DEEP_DEPENDENCIES
end
end

# Report Creation Utilities
UTILITY_NAME_GCOVR = "gcovr"
UTILITY_NAME_REPORT_GENERATOR = "ReportGenerator"
UTILITY_NAMES = [UTILITY_NAME_GCOVR, UTILITY_NAME_REPORT_GENERATOR]

namespace UTILS_SYM do
# Report Creation Utilities
UTILITY_NAME_GCOVR = "gcovr"
UTILITY_NAME_REPORT_GENERATOR = "ReportGenerator"
UTILITY_NAMES = [UTILITY_NAME_GCOVR, UTILITY_NAME_REPORT_GENERATOR]

# Returns true is the given utility is enabled, otherwise returns false.
def is_utility_enabled(opts, utility_name)
return !(opts.nil?) && !(opts[:gcov_utilities].nil?) && (opts[:gcov_utilities].map(&:upcase).include? utility_name.upcase)
end


desc "Create gcov code coverage html/xml/json/text report(s). (Note: Must run 'ceedling gcov' first)."
task GCOV_SYM do
# Get the gcov options from project.yml.
Expand Down
2 changes: 1 addition & 1 deletion spec/build_invoker_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# these keep the actual test cleaner
@exception_msg = 'Don\'t know how to build task \'xyz\''
@basic_msg = "ERROR: Rake could not find file referenced in source or test: 'xyz'. Possible stale dependency."
@deep_dep_msg = "Try fixing #include statements or adding missing file. Then run '#{REFRESH_TASK_ROOT}#{TEST_SYM.to_s}' task and try again."
@deep_dep_msg = "Try fixing #include statements or adding missing file. Then run '#{REFRESH_TASK_ROOT}#{TEST_SYM}' task and try again."
@exception = RuntimeError.new(@exception_msg)
end

Expand Down
10 changes: 4 additions & 6 deletions spec/spec_system_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def lib; File.join(@d, 'lib') end
end

class SystemContext
class VerificationFailed < Exception; end
class InvalidBackupEnv < Exception; end
class VerificationFailed < RuntimeError; end
class InvalidBackupEnv < RuntimeError; end

attr_reader :dir, :gem

Expand All @@ -69,7 +69,7 @@ def deploy_gem
git_repo = File.expand_path(File.join(File.dirname(__FILE__), '..'))
bundler_gem_file_data = [ %Q{source "http://rubygems.org/"},
%Q{gem "rake"},
%Q{gem "ceedling", :path => '#{git_repo.to_s}'}
%Q{gem "ceedling", :path => '#{git_repo}'}
].join("\n")

File.open(File.join(@dir, "Gemfile"), "w+") do |f|
Expand Down Expand Up @@ -622,13 +622,11 @@ def handles_creating_the_same_module_twice_using_the_module_plugin
output = `bundle exec ruby -S ceedling module:create[unicorns] 2>&1`
expect($?.exitstatus).to match(1)
expect(output).to match(/ERROR: Ceedling Failed/)

self.handles_creating_the_same_module_twice_using_the_module_plugin_path_extension
end
end
end

def handles_creating_the_same_module_twice_using_the_module_plugin
def handles_creating_the_same_module_twice_using_the_module_plugin_extension
@c.with_context do
Dir.chdir @proj_name do
output = `bundle exec ruby -S ceedling module:create[myUnicorn:unicorns]`
Expand Down
4 changes: 4 additions & 0 deletions spec/system/deployment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
it { can_use_the_module_plugin_with_include_path }
it { can_use_the_module_plugin_with_non_default_paths }
it { handles_creating_the_same_module_twice_using_the_module_plugin }
it { handles_creating_the_same_module_twice_using_the_module_plugin_extension }
it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin_path_extension }
end
Expand Down Expand Up @@ -121,6 +122,7 @@
it { can_use_the_module_plugin_with_include_path }
it { can_use_the_module_plugin_with_non_default_paths }
it { handles_creating_the_same_module_twice_using_the_module_plugin }
it { handles_creating_the_same_module_twice_using_the_module_plugin_extension }
it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin_path_extension }

Expand All @@ -143,6 +145,7 @@
it { can_use_the_module_plugin_with_include_path }
it { can_use_the_module_plugin_with_non_default_paths }
it { handles_creating_the_same_module_twice_using_the_module_plugin }
it { handles_creating_the_same_module_twice_using_the_module_plugin_extension }
it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin_path_extension }
end
Expand Down Expand Up @@ -171,6 +174,7 @@
it { can_use_the_module_plugin_with_include_path }
it { can_use_the_module_plugin_with_non_default_paths }
it { handles_creating_the_same_module_twice_using_the_module_plugin }
it { handles_creating_the_same_module_twice_using_the_module_plugin_extension }
it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin_path_extension }
end
Expand Down

0 comments on commit ce33f29

Please sign in to comment.