rubocop-eightyfourcodes 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +16 -0
  4. data/CHANGELOG.md +5 -0
  5. data/Gemfile +9 -3
  6. data/Gemfile.lock +75 -0
  7. data/LICENSE.md +7 -5
  8. data/README.md +13 -61
  9. data/Rakefile +32 -0
  10. data/config/default.yml +36 -8
  11. data/lib/rubocop/cop/eighty_four_codes/command_literal_injection.rb +4 -2
  12. data/lib/rubocop/cop/eighty_four_codes/ensure_redirect.rb +48 -0
  13. data/lib/rubocop/cop/eighty_four_codes/ruby_version_file.rb +30 -34
  14. data/lib/rubocop/cop/eightyfourcodes_cops.rb +12 -0
  15. data/lib/rubocop/cop/gitlab_security/deep_munge.rb +36 -0
  16. data/lib/rubocop/cop/gitlab_security/json_serialization.rb +137 -0
  17. data/lib/rubocop/cop/gitlab_security/public_send.rb +47 -0
  18. data/lib/rubocop/cop/gitlab_security/redirect_to_params_update.rb +38 -0
  19. data/lib/rubocop/cop/gitlab_security/send_file_params.rb +40 -0
  20. data/lib/rubocop/cop/gitlab_security/sql_injection.rb +41 -0
  21. data/lib/rubocop/cop/gitlab_security/system_command_injection.rb +38 -0
  22. data/lib/rubocop/{eighty_four_codes → eightyfourcodes}/inject.rb +5 -1
  23. data/lib/rubocop/eightyfourcodes/version.rb +7 -0
  24. data/lib/rubocop/{eighty_four_codes.rb → eightyfourcodes.rb} +6 -1
  25. data/lib/rubocop-eightyfourcodes.rb +5 -16
  26. data/rubocop-eightyfourcodes.gemspec +22 -23
  27. data/sig/rubocop/eightyfourcodes.rbs +6 -0
  28. metadata +32 -50
  29. data/CONTRIBUTING.md +0 -3
  30. data/lib/rubocop/cop/eighty_four_codes/cop.rb +0 -70
  31. data/lib/rubocop/cop/eighty_four_codes/shell_escape.rb +0 -62
  32. data/lib/rubocop/eighty_four_codes/concept.rb +0 -34
  33. data/lib/rubocop/eighty_four_codes/config_formatter.rb +0 -33
  34. data/lib/rubocop/eighty_four_codes/description_extractor.rb +0 -72
  35. data/lib/rubocop/eighty_four_codes/example.rb +0 -32
  36. data/lib/rubocop/eighty_four_codes/example_group.rb +0 -95
  37. data/lib/rubocop/eighty_four_codes/hook.rb +0 -49
  38. data/lib/rubocop/eighty_four_codes/language/node_pattern.rb +0 -20
  39. data/lib/rubocop/eighty_four_codes/language.rb +0 -118
  40. data/lib/rubocop/eighty_four_codes/top_level_describe.rb +0 -57
  41. data/lib/rubocop/eighty_four_codes/util.rb +0 -19
  42. data/lib/rubocop/eighty_four_codes/version.rb +0 -10
  43. data/lib/rubocop/eighty_four_codes/wording.rb +0 -81
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module EightyFourCodes
5
- # RSpec example wording rewriter
6
- class Wording
7
- SHOULDNT_PREFIX = /\Ashould(?:n't| not)\b/i
8
- SHOULDNT_BE_PREFIX = /#{SHOULDNT_PREFIX} be\b/i
9
- ES_SUFFIX_PATTERN = /(?:o|s|x|ch|sh|z)\z/i
10
- IES_SUFFIX_PATTERN = /[^aeou]y\z/i
11
-
12
- def initialize(text, ignore:, replace:)
13
- @text = text
14
- @ignores = ignore
15
- @replacements = replace
16
- end
17
-
18
- def rewrite
19
- case text
20
- when SHOULDNT_BE_PREFIX
21
- replace_prefix(SHOULDNT_BE_PREFIX, 'is not')
22
- when SHOULDNT_PREFIX
23
- replace_prefix(SHOULDNT_PREFIX, 'does not')
24
- else
25
- remove_should_and_pluralize
26
- end
27
- end
28
-
29
- private
30
-
31
- attr_reader :text, :ignores, :replacements
32
-
33
- def replace_prefix(pattern, replacement)
34
- text.sub(pattern) do |shouldnt|
35
- uppercase?(shouldnt) ? replacement.upcase : replacement
36
- end
37
- end
38
-
39
- def uppercase?(word)
40
- word.upcase.eql?(word)
41
- end
42
-
43
- def remove_should_and_pluralize
44
- _should, *words = text.split
45
-
46
- words.each_with_index do |word, index|
47
- next if ignored_word?(word)
48
-
49
- words[index] = substitute(word)
50
-
51
- break
52
- end
53
-
54
- words.join(' ')
55
- end
56
-
57
- def ignored_word?(word)
58
- ignores.any? { |ignore| ignore.casecmp(word).zero? }
59
- end
60
-
61
- def substitute(word)
62
- # NOTE: Custom replacements are case sensitive.
63
- return replacements.fetch(word) if replacements.key?(word)
64
-
65
- case word
66
- when ES_SUFFIX_PATTERN then append_suffix(word, 'es')
67
- when IES_SUFFIX_PATTERN then append_suffix(word[0..-2], 'ies')
68
- else append_suffix(word, 's')
69
- end
70
- end
71
-
72
- def append_suffix(word, suffix)
73
- suffix = suffix.upcase if uppercase?(word)
74
-
75
- "#{word}#{suffix}"
76
- end
77
-
78
- private_constant(*constants(false))
79
- end
80
- end
81
- end