From 937b8feaef8909b758d3b7b2217da4f772b712ff Mon Sep 17 00:00:00 2001 From: Rufus Post Date: Fri, 19 Dec 2014 15:34:26 +1100 Subject: [PATCH] Add rubocop to project This adds https://github.com/bbatsov/rubocop to the project with an auto generated `.rubocop_todo.yml`. The violations can be addressed over time without breaking the build. Also added is the `rake ci` task that runs `test` and `rubocop` only on mri. The `rubotest` task is the same is `rake ci` but will run on all rubies, the default rake task just runs test as per usual. Conflicts: net-ldap.gemspec --- .rubocop.yml | 5 + .rubocop_todo.yml | 462 ++++++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 2 +- README.rdoc | 15 ++ Rakefile | 15 +- net-ldap.gemspec | 1 + 6 files changed, 497 insertions(+), 3 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..85ffa202 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,5 @@ +inherit_from: .rubocop_todo.yml + +AllCops: + Exclude: + - 'pkg/**/*' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..5a5dcbc7 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,462 @@ +# This configuration was generated by `rubocop --auto-gen-config` +# on 2014-12-19 15:32:44 +1100 using RuboCop version 0.28.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: 12 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Enabled: false + +# Offense count: 1 +# Configuration parameters: AlignWith, SupportedStyles. +Lint/EndAlignment: + Enabled: false + +# Offense count: 1 +Lint/RescueException: + Enabled: false + +# Offense count: 1 +Lint/ShadowingOuterLocalVariable: + Enabled: false + +# Offense count: 9 +# Cop supports --auto-correct. +Lint/UnusedBlockArgument: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +Lint/UnusedMethodArgument: + Enabled: false + +# Offense count: 7 +Lint/UselessAssignment: + Enabled: false + +# Offense count: 47 +Metrics/AbcSize: + Max: 114 + +# Offense count: 11 +Metrics/BlockNesting: + Max: 4 + +# Offense count: 9 +# Configuration parameters: CountComments. +Metrics/ClassLength: + Max: 470 + +# Offense count: 20 +Metrics/CyclomaticComplexity: + Max: 41 + +# Offense count: 193 +# Configuration parameters: AllowURI, URISchemes. +Metrics/LineLength: + Max: 360 + +# Offense count: 71 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 130 + +# Offense count: 13 +Metrics/PerceivedComplexity: + Max: 36 + +# Offense count: 1 +Style/AccessorMethodName: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +Style/AlignArray: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/AlignParameters: + Enabled: false + +# Offense count: 36 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/AndOr: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/BarePercentLiterals: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/BlockComments: + Enabled: false + +# Offense count: 20 +# Cop supports --auto-correct. +Style/Blocks: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/BracesAroundHashParameters: + Enabled: false + +# Offense count: 4 +# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep. +Style/CaseIndentation: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +Style/CharacterLiteral: + Enabled: false + +# Offense count: 22 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/ClassAndModuleChildren: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/ClassCheck: + Enabled: false + +# Offense count: 13 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Enabled: false + +# Offense count: 2 +# Configuration parameters: Keywords. +Style/CommentAnnotation: + Enabled: false + +# Offense count: 86 +Style/ConstantName: + Enabled: false + +# Offense count: 18 +# Cop supports --auto-correct. +Style/DeprecatedHashMethods: + Enabled: false + +# Offense count: 46 +Style/Documentation: + Enabled: false + +# Offense count: 23 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/DotPosition: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ElseAlignment: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs. +Style/EmptyLineBetweenDefs: + Enabled: false + +# Offense count: 9 +# Cop supports --auto-correct. +Style/EmptyLines: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/EmptyLinesAroundClassBody: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/EmptyLinesAroundModuleBody: + Enabled: false + +# Offense count: 3 +Style/EvenOdd: + Enabled: false + +# Offense count: 1 +# Configuration parameters: Exclude. +Style/FileName: + Enabled: false + +# Offense count: 9 +# Configuration parameters: AllowedVariables. +Style/GlobalVars: + Enabled: false + +# Offense count: 3 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Enabled: false + +# Offense count: 150 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/HashSyntax: + Enabled: false + +# Offense count: 8 +# Configuration parameters: MaxLineLength. +Style/IfUnlessModifier: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/IndentHash: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: Width. +Style/IndentationWidth: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/LeadingCommentSpace: + Enabled: false + +# Offense count: 21 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/MethodDefParentheses: + Enabled: false + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/MethodName: + Enabled: false + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/MultilineOperationIndentation: + Enabled: false + +# Offense count: 1 +Style/MultilineTernaryOperator: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NegatedIf: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NegatedWhile: + Enabled: false + +# Offense count: 3 +# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +Style/Next: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NilComparison: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IncludeSemanticChanges. +Style/NonNilCheck: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Not: + Enabled: false + +# Offense count: 10 +# Cop supports --auto-correct. +Style/NumericLiterals: + MinDigits: 8 + +# Offense count: 3 +Style/OpMethod: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: AllowSafeAssignment. +Style/ParenthesesAroundCondition: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Enabled: false + +# Offense count: 11 +# Cop supports --auto-correct. +Style/PerlBackrefs: + Enabled: false + +# Offense count: 9 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/RaiseArgs: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantBegin: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Enabled: false + +# Offense count: 7 +# Cop supports --auto-correct. +Style/RedundantSelf: + Enabled: false + +# Offense count: 1 +# Configuration parameters: MaxSlashes. +Style/RegexpLiteral: + Enabled: false + +# Offense count: 2 +Style/RescueModifier: + Enabled: false + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Enabled: false + +# Offense count: 61 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/SignalException: + Enabled: false + +# Offense count: 2 +# Configuration parameters: Methods. +Style/SingleLineBlockParams: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/SingleSpaceBeforeFirstArg: + Enabled: false + +# Offense count: 24 +# Cop supports --auto-correct. +Style/SpaceAfterComma: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/SpaceAroundEqualsInParameterDefault: + Enabled: false + +# Offense count: 8 +# Cop supports --auto-correct. +Style/SpaceAroundOperators: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/SpaceBeforeBlockBraces: + Enabled: false + +# Offense count: 18 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +Style/SpaceInsideBlockBraces: + Enabled: false + +# Offense count: 37 +# Cop supports --auto-correct. +Style/SpaceInsideBrackets: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. +Style/SpaceInsideHashLiteralBraces: + Enabled: false + +# Offense count: 20 +# Cop supports --auto-correct. +Style/SpaceInsideParens: + Enabled: false + +# Offense count: 5 +# Cop supports --auto-correct. +Style/SpecialGlobalVars: + Enabled: false + +# Offense count: 645 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/StringLiterals: + Enabled: false + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +Style/SymbolProc: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/TrailingBlankLines: + Enabled: false + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. +Style/TrailingComma: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist. +Style/TrivialAccessors: + Enabled: false + +# Offense count: 5 +# Cop supports --auto-correct. +Style/UnneededPercentQ: + Enabled: false + +# Offense count: 1 +# Configuration parameters: MaxLineLength. +Style/WhileUntilModifier: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +Style/WordArray: + MinSize: 2 diff --git a/.travis.yml b/.travis.yml index c1247468..311ed4c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ install: - if [ "$INTEGRATION" = "openldap" ]; then ./script/install-openldap; fi - bundle install -script: bundle exec rake +script: bundle exec rake ci matrix: allow_failures: diff --git a/README.rdoc b/README.rdoc index e34162b8..b8331f7c 100644 --- a/README.rdoc +++ b/README.rdoc @@ -37,12 +37,27 @@ sources. Simply require either 'net-ldap' or 'net/ldap'. +== Develop + +This task will run the test suite and the +{RuboCop}[https://github.com/bbatsov/rubocop] static code analyzer. + + rake rubotest + +To run the integration tests against an LDAP server: + + cd test/support/vm/openldap + vagrant up + cd ../../../.. + INTEGRATION=openldap bundle exec rake rubotest + == Release This section is for gem maintainers to cut a new version of the gem. * Update lib/net/ldap/version.rb to next version number X.X.X following {semver}(http://semver.org/). * Update `History.rdoc`. Get latest changes with `git log --oneline vLAST_RELEASE..HEAD | grep Merge` + * On the master branch, run `script/release` :include: Contributors.rdoc diff --git a/Rakefile b/Rakefile index edc8fc75..85a70153 100644 --- a/Rakefile +++ b/Rakefile @@ -3,11 +3,22 @@ # vim: syntax=ruby require 'rake/testtask' +require 'rubocop/rake_task' +require 'bundler' + +RuboCop::RakeTask.new Rake::TestTask.new do |t| - t.libs << "test" + t.libs << 'test' t.test_files = FileList['test/**/test_*.rb'] t.verbose = true + t.description = 'Run tests, set INTEGRATION=openldap to run integration tests, INTEGRATION_HOST and INTEGRATION_PORT are also supported' end -task :default => :test +desc 'Run tests and RuboCop (RuboCop runs on mri only)' +task ci: Bundler.current_ruby.mri? ? [:test, :rubocop] : [:test] + +desc 'Run tests and RuboCop' +task rubotest: [:test, :rubocop] + +task default: :test diff --git a/net-ldap.gemspec b/net-ldap.gemspec index 76299ac7..7cdd29db 100644 --- a/net-ldap.gemspec +++ b/net-ldap.gemspec @@ -31,4 +31,5 @@ the most recent LDAP RFCs (4510-4519, plutions of 4520-4532).} s.add_development_dependency("flexmock", "~> 1.3") s.add_development_dependency("rake", "~> 10.0") + s.add_development_dependency("rubocop", "~> 0.28.0") end