1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 08:25:58 +01:00

Starting to enforce our coding style. The first step is that we’ve pulled in Rubocop to check out Ruby syntax. There is likely a bit of customization to do yet AND there is definitely that backlog of todo’s that we just told it to ignore.

This commit is contained in:
Mark VanderVoord
2017-03-28 08:44:32 -04:00
parent 550d58ba2d
commit 3062c39725
18 changed files with 1414 additions and 910 deletions

6
test/.rubocop.yml Normal file
View File

@@ -0,0 +1,6 @@
# This is the configuration used to check the rubocop source code.
inherit_from: .rubocop_todo.yml
AllCops:
TargetRubyVersion: 2.1

510
test/.rubocop_todo.yml Normal file
View File

@@ -0,0 +1,510 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-03-28 08:23:05 -0400 using RuboCop version 0.48.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 2
Lint/AmbiguousBlockAssociation:
Exclude:
- '../auto/generate_module.rb'
# Offense count: 1
# Cop supports --auto-correct.
Lint/DeprecatedClassMethods:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Lint/EndAlignment:
Exclude:
- '../auto/colour_prompt.rb'
- '../auto/colour_reporter.rb'
- '../auto/generate_module.rb'
- '../auto/parseOutput.rb'
- '../auto/stylize_as_junit.rb'
# Offense count: 2
Lint/RescueException:
Exclude:
- '../auto/stylize_as_junit.rb'
- '../auto/unity_test_summary.rb'
# Offense count: 2
Lint/ShadowingOuterLocalVariable:
Exclude:
- '../auto/generate_module.rb'
- '../auto/stylize_as_junit.rb'
# Offense count: 3
# Cop supports --auto-correct.
Lint/StringConversionInInterpolation:
Exclude:
- 'tests/test_generate_test_runner.rb'
# Offense count: 13
Lint/UselessAssignment:
Exclude:
- '../auto/generate_test_runner.rb'
- '../auto/stylize_as_junit.rb'
- '../auto/unity_test_summary.rb'
- 'rakefile_helper.rb'
# Offense count: 5
Lint/Void:
Exclude:
- '../auto/parseOutput.rb'
# Offense count: 45
Metrics/AbcSize:
Max: 80
# Offense count: 6
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 89
# Offense count: 4
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 341
# Offense count: 14
Metrics/CyclomaticComplexity:
Max: 17
# Offense count: 226
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 154
# Offense count: 39
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 58
# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 204
# Offense count: 13
Metrics/PerceivedComplexity:
Max: 19
# Offense count: 2
# Cop supports --auto-correct.
Performance/StringReplacement:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 1
# Cop supports --auto-correct.
Security/YAMLLoad:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 10
Style/AccessorMethodName:
Exclude:
- '../auto/stylize_as_junit.rb'
- '../auto/unity_test_summary.rb'
- '../examples/example_3/rakefile_helper.rb'
- 'rakefile_helper.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
# SupportedStyles: line_count_based, semantic, braces_for_chaining
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
# FunctionalMethods: let, let!, subject, watch
# IgnoredMethods: lambda, proc, it
Style/BlockDelimiters:
Exclude:
- 'spec/generate_module_existing_file_spec.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 12
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- '../auto/colour_prompt.rb'
- '../auto/generate_module.rb'
- '../auto/generate_test_runner.rb'
- '../auto/parseOutput.rb'
- '../auto/stylize_as_junit.rb'
- '../auto/test_file_filter.rb'
- '../auto/type_sanitizer.rb'
- '../auto/unity_test_summary.rb'
- '../examples/example_3/rakefile_helper.rb'
- '../extras/fixture/rakefile_helper.rb'
- 'rakefile_helper.rb'
# Offense count: 2
# Cop supports --auto-correct.
Style/ElseAlignment:
Exclude:
- '../auto/generate_test_runner.rb'
# Offense count: 3
# Cop supports --auto-correct.
Style/EmptyLines:
Exclude:
- 'tests/test_generate_test_runner.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundBlockBody:
Exclude:
- 'rakefile_helper.rb'
- 'spec/generate_module_existing_file_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
Style/EmptyLinesAroundModuleBody:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 14
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Style/ExtraSpacing:
Exclude:
- '../auto/generate_test_runner.rb'
- 'rakefile_helper.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Style/FileName:
Exclude:
- '../auto/parseOutput.rb'
# Offense count: 4
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Exclude:
- '../auto/generate_module.rb'
# Offense count: 164
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Exclude:
- '../auto/colour_reporter.rb'
- '../examples/example_3/rakefile_helper.rb'
- '../extras/fixture/rakefile.rb'
- '../extras/fixture/rakefile_helper.rb'
- 'rakefile_helper.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 20
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- '../auto/colour_prompt.rb'
- '../auto/generate_test_runner.rb'
- '../auto/parseOutput.rb'
- '../auto/stylize_as_junit.rb'
- '../auto/test_file_filter.rb'
- '../auto/unity_test_summary.rb'
- '../extras/fixture/rakefile_helper.rb'
- 'rakefile_helper.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 630
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'rakefile_helper.rb'
- 'spec/generate_module_existing_file_spec.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IndentationWidth.
Style/IndentAssignment:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Style/IndentationWidth:
Exclude:
- '../auto/generate_test_runner.rb'
- 'spec/generate_module_existing_file_spec.rb'
# Offense count: 17
# Cop supports --auto-correct.
Style/LeadingCommentSpace:
Exclude:
- 'rakefile_helper.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 1
# Cop supports --auto-correct.
Style/LineEndConcatenation:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 8
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, camelCase
Style/MethodName:
Exclude:
- '../auto/parseOutput.rb'
# Offense count: 40
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Style/MultilineArrayBraceLayout:
Exclude:
- 'tests/test_generate_test_runner.rb'
# Offense count: 63
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Style/MultilineHashBraceLayout:
Exclude:
- 'tests/test_generate_test_runner.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented
Style/MultilineOperationIndentation:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 3
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'rakefile_helper.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: both, prefix, postfix
Style/NegatedIf:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 1
# Cop supports --auto-correct.
Style/Not:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- '../auto/colour_reporter.rb'
- '../auto/generate_module.rb'
# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: AllowSafeAssignment.
Style/ParenthesesAroundCondition:
Exclude:
- '../auto/generate_test_runner.rb'
- 'rakefile_helper.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 7
# Cop supports --auto-correct.
Style/RedundantParentheses:
Exclude:
- '../auto/generate_test_runner.rb'
- 'rakefile_helper.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Exclude:
- 'rakefile_helper.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Exclude:
- '../auto/generate_test_runner.rb'
- '../auto/stylize_as_junit.rb'
- '../auto/type_sanitizer.rb'
- '../auto/unity_test_summary.rb'
- '../extras/fixture/rakefile_helper.rb'
- 'rakefile_helper.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AllowAsExpressionSeparator.
Style/Semicolon:
Exclude:
- '../auto/generate_test_runner.rb'
# Offense count: 5
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Exclude:
- 'tests/test_generate_test_runner.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleInsidePipes, SupportedStylesInsidePipes.
# SupportedStylesInsidePipes: space, no_space
Style/SpaceAroundBlockParameters:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Style/SpaceAroundOperators:
Exclude:
- 'rakefile_helper.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceBeforeBlockBraces:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Style/SpaceInsideBlockBraces:
Exclude:
- 'rakefile_helper.rb'
- 'spec/generate_module_existing_file_spec.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 295
# Cop supports --auto-correct.
Style/SpaceInsideBrackets:
Exclude:
- 'tests/test_generate_test_runner.rb'
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBraces: space, no_space
Style/SpaceInsideHashLiteralBraces:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 5
# Cop supports --auto-correct.
Style/SpaceInsideParens:
Exclude:
- 'tests/test_generate_test_runner.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: use_perl_names, use_english_names
Style/SpecialGlobalVars:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 167
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'rakefile_helper.rb'
- 'spec/generate_module_existing_file_spec.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
Style/TernaryParentheses:
Exclude:
- 'rakefile_helper.rb'
# Offense count: 152
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInLiteral:
Exclude:
- 'spec/generate_module_existing_file_spec.rb'
- 'tests/test_generate_test_runner.rb'
# Offense count: 39
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, camelCase
Style/VariableName:
Exclude:
- '../auto/parseOutput.rb'
# Offense count: 69
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: percent
MinSize: 12
# Offense count: 1
# Cop supports --auto-correct.
Style/ZeroLengthPredicate:
Exclude:
- 'rakefile_helper.rb'

View File

@@ -53,7 +53,7 @@ task :summary do
end
desc "Build and test Unity"
task :all => [:clean, :prepare_for_tests, :scripts, :unit, :summary]
task :all => [:clean, :prepare_for_tests, :scripts, :unit, :style, :summary]
task :default => [:clobber, :all]
task :ci => [:no_color, :default]
task :cruise => [:no_color, :default]
@@ -70,3 +70,25 @@ end
task :verbose do
$verbose = true
end
namespace :style do
desc "Check style"
task :check do
`rubocop ../`
report "Style Checked."
end
desc "Attempt to Autocorrect style"
task :auto do
`rubocop ../ --auto-correct`
report "Autocorrected What We Could."
end
desc "Update style todo list"
task :todo do
`rubocop ../ --auto-gen-config`
report "Updated Style TODO List."
end
end
task :style => ['style:check']

View File

@@ -1170,11 +1170,11 @@ def runner_test(test, runner, expected, test_defines, cmdline_args)
simulator = build_simulator_fields
cmdline_args ||= ""
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] + " #{cmdline_args}"
if simulator.nil?
cmd_str = executable
else
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
end
cmd_str = if simulator.nil?
executable
else
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
end
output = execute(cmd_str, true)
#compare to the expected pass/fail