Install standardized flog/flay Rake tasks and a pre-commit hook that runs bundle exec rake for Ruby projects. Use when adding or normalizing code complexity and duplication checks.
Inspect the existing Gemfile, Rakefile, CI, and hooks first. Add flog and flay to the development/test dependency group and use the project’s normal lockfile workflow.
Add require "open3", thresholds that default to 25 for flog and 10 for flay, and these tasks. Scores equal to a threshold fail.
FLOG_THRESHOLD = (ENV["FLOG_THRESHOLD"] || 25).to_i
FLAY_THRESHOLD = (ENV["FLAY_THRESHOLD"] || 10).to_i
desc "Run flog"
task :flog do
output, status = Open3.capture2e("bundle", "exec", "flog", "-a", "lib")
puts output
abort "flog failed to run" unless status.success?
scores = output.lines.filter_map do |line|
line[/^\s+([0-9]+\.[0-9]+):.*(?:#|::)/, 1]&.to_f unless line.include?("main#none")
end
maximum = scores.max || 0.0
abort "flog failed: #{maximum} reached #{FLOG_THRESHOLD}" if maximum >= FLOG_THRESHOLD
puts "flog passed (#{maximum} < #{FLOG_THRESHOLD})"
end
desc "Run flay"
task :flay do
output, = Open3.capture2e("bundle", "exec", "flay", "lib")
puts output
score = output[/Total score.*?=\s*(\d+)/, 1]&.to_i
abort "flay failed: no parseable total score" unless score
abort "flay failed: #{score} reached #{FLAY_THRESHOLD}" if score >= FLAY_THRESHOLD
puts "flay passed (#{score} < #{FLAY_THRESHOLD})"
end
Scope the commands to maintained project sources (lib here); adapt that explicit source root when the project differs. Add both tasks to the default or lint dependency graph and to pre-commit without duplicating existing hooks.
Run each task directly, then the aggregate task. Confirm a class-method score at the threshold fails, malformed tool output fails, a parsed below-threshold score passes, and the hook invokes the aggregate task. Completion requires the lockfile, tasks, and hook configuration to agree.
npx skills add nateberkopec/ruby-flog-flay-setup下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer