Skip to content

Commit b7fdde1

Browse files
committed
Update RuboCop configuration and enhance gemspec description. Added exclusions for metrics in RuboCop, improved formatting in the gemspec, and refined generator options for better clarity and usability.
1 parent 8c3a03a commit b7fdde1

File tree

12 files changed

+67
-43
lines changed

12 files changed

+67
-43
lines changed

.rubocop.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
11
AllCops:
22
TargetRubyVersion: 3.1
3+
NewCops: enable
4+
SuggestExtensions: false
35

46
Style/StringLiterals:
57
EnforcedStyle: double_quotes
68

79
Style/StringLiteralsInInterpolation:
810
EnforcedStyle: double_quotes
11+
12+
Metrics/BlockLength:
13+
Exclude:
14+
- "lib/tasks/**/*.rake"
15+
- "Rakefile"
16+
- "memory_bank_rails.gemspec"
17+
18+
Layout/LineLength:
19+
Max: 120
20+
Exclude:
21+
- "lib/generators/**"
22+
23+
Style/Documentation:
24+
Enabled: false
25+
26+
Metrics/MethodLength:
27+
Max: 25
28+
Exclude:
29+
- "lib/generators/**"
30+
31+
Metrics/AbcSize:
32+
Max: 26
33+
Exclude:
34+
- "lib/generators/**"
35+
36+
Metrics/ClassLength:
37+
Max: 120
38+
Exclude:
39+
- "lib/generators/**"

lib/generators/memory_bank/install/install_generator.rb

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ module Generators
99
class InstallGenerator < Rails::Generators::Base
1010
source_root File.expand_path("templates", __dir__)
1111

12-
class_option :guide, type: :string, default: "select", desc: "Which guide to install (or 'select' to choose interactively)"
13-
class_option :with_rules, type: :boolean, default: false, desc: "Copy editor rules (.cursorrules, RuboCop, Solargraph) if available"
12+
class_option :guide,
13+
type: :string,
14+
default: "select",
15+
desc: "Which guide to install (or 'select' to choose interactively)"
16+
class_option :with_rules,
17+
type: :boolean,
18+
default: false,
19+
desc: "Copy editor rules (.cursorrules, RuboCop, Solargraph) if available"
1420

1521
def create_config
1622
template "config/memory_bank.yml.erb", "config/memory_bank.yml"
@@ -66,9 +72,8 @@ def resolve_guide_source(guide, guides_path)
6672
def select_guide_interactively(guides_path)
6773
builtin = available_builtin_guides
6874
external = available_external_guides(guides_path)
69-
options = []
70-
builtin.each { |g| options << ["📦 #{g} (builtin)", :builtin, g, nil] }
71-
external.each { |g, path| options << ["🔧 #{g} (external)", :external, g, path] }
75+
options = builtin.map { |g| ["📦 #{g} (builtin)", :builtin, g, nil] } +
76+
external.map { |g, path| ["🔧 #{g} (external)", :external, g, path] }
7277

7378
if options.empty?
7479
say "No guides available. Falling back to builtin 'rails_web'", :yellow
@@ -78,11 +83,11 @@ def select_guide_interactively(guides_path)
7883
say "\n🚀 Memory Bank Initializer (Rails)", :green
7984
say "=================================\n"
8085
options.each_with_index do |(label, _kind, _slug, _path), idx|
81-
say format("%2d) %s", idx + 1, label)
86+
say format("%<num>2d) %<label>s", num: idx + 1, label: label)
8287
end
8388
choice = ask("\n? What type of memory bank would you like to install? (1-#{options.size})").to_i
8489
choice = 1 if choice < 1 || choice > options.size
85-
label, kind, slug, full_path = options[choice - 1]
90+
_label, kind, slug, full_path = options[choice - 1]
8691
[slug, kind, full_path]
8792
end
8893

@@ -94,8 +99,10 @@ def available_builtin_guides
9499

95100
def available_external_guides(guides_path)
96101
return [] unless guides_path
102+
97103
expanded = File.expand_path(guides_path)
98104
return [] unless Dir.exist?(expanded)
105+
99106
Dir.children(expanded).filter_map do |entry|
100107
full = File.join(expanded, entry)
101108
guide_md = File.join(full, "developmentGuide.md")
@@ -112,9 +119,9 @@ def copy_external_guide_files(external_dir)
112119
FileUtils.cp(source_md, File.join(destination_root, ".memory_bank", "developmentGuide.md"))
113120

114121
rules = File.join(external_dir, ".cursorrules")
115-
if options["with_rules"] && File.exist?(rules)
116-
FileUtils.cp(rules, File.join(destination_root, ".cursorrules"))
117-
end
122+
return unless options["with_rules"] && File.exist?(rules)
123+
124+
FileUtils.cp(rules, File.join(destination_root, ".cursorrules"))
118125
end
119126

120127
def install_editor_rules
@@ -131,5 +138,3 @@ def install_editor_rules
131138
end
132139
end
133140
end
134-
135-

lib/memory_bank_rails/cli.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ def self.load_rake_tasks
3636
end
3737

3838
# Backwards compatible alias used in README one-off example
39+
3940
module MemoryBank
4041
class CLI
4142
def self.run(command)
4243
MemoryBankRails::CLI.run(command)
4344
end
4445
end
4546
end
46-
47-

lib/memory_bank_rails/config.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,3 @@ def self.deep_merge(base, override)
3434
end
3535
end
3636
end
37-
38-

lib/memory_bank_rails/railtie.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module MemoryBankRails
66
class Railtie < ::Rails::Railtie
77
rake_tasks do
8-
load File.expand_path('../tasks/memory_bank_rails.rake', __dir__)
8+
load File.expand_path("../tasks/memory_bank_rails.rake", __dir__)
99
end
1010

1111
# Autoload generators
@@ -16,5 +16,3 @@ class Railtie < ::Rails::Railtie
1616
end
1717
end
1818
end
19-
20-

lib/memory_bank_rails/services/checker.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,17 @@ def initialize(root_path)
1616
@root_path = root_path
1717
end
1818

19-
def verify!
19+
def verify?
2020
missing = REQUIRED_FILES.reject { |p| File.exist?(File.join(@root_path, p)) }
2121
if missing.empty?
2222
puts "Memory Bank: OK"
2323
true
2424
else
25-
puts "Missing files:"
25+
puts "Missing files:"
2626
missing.each { |m| puts " - #{m}" }
2727
false
2828
end
2929
end
3030
end
3131
end
3232
end
33-
34-

lib/memory_bank_rails/services/filesystem.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,3 @@ def file_exists?(relative_path)
3535
end
3636
end
3737
end
38-
39-

lib/memory_bank_rails/services/initializer.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ def initialize_docs
2525
end
2626
end
2727
end
28-
29-

lib/memory_bank_rails/services/report.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def generate
1616

1717
Dir.glob(File.join(specs_root, "**", "*.md")).each do |file|
1818
content = File.read(file)
19-
total += content.scan(/\- \[.\]/).size
20-
done += content.scan(/\- \[x\]/i).size
19+
total += content.scan(/- \[.\]/).size
20+
done += content.scan(/- \[x\]/i).size
2121
end
2222

2323
percent = total.zero? ? 0 : ((done.to_f / total) * 100).round(1)
@@ -26,5 +26,3 @@ def generate
2626
end
2727
end
2828
end
29-
30-

lib/memory_bank_rails/services/spec_generator.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
module MemoryBankRails
66
module Services
7+
# Generates SPEC scaffolding files under `.specs/<feature-slug>`.
78
class SpecGenerator
89
def initialize(root_path)
910
@fs = Filesystem.new(root_path)
@@ -58,5 +59,3 @@ def tasks_template(feature_slug)
5859
end
5960
end
6061
end
61-
62-

0 commit comments

Comments
 (0)