repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/source_control_systems/interfaces/time_travel.rb | test/lib/rubycritic/source_control_systems/interfaces/time_travel.rb | # frozen_string_literal: true
# This interface is only used if `@system.revision?` returns `true`.
module TimeTravelInterface
def test_implements_time_travel_interface
assert_respond_to @system, :head_reference
assert_respond_to @system, :travel_to_head
end
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/source_control_systems/git/churn_test.rb | test/lib/rubycritic/source_control_systems/git/churn_test.rb | # frozen_string_literal: true
require 'test_helper'
describe RubyCritic::SourceControlSystem::Git::Churn do
let(:churn) { RubyCritic::SourceControlSystem::Git::Churn.new }
before do
RubyCritic::SourceControlSystem::Git.stubs(:git).returns(git_log)
end
let(:git_log) do
<<~GIT_LOG
date:\t2020-06... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/core/smells_array_test.rb | test/lib/rubycritic/core/smells_array_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'rubycritic/core/smell'
describe 'Array of Smells' do
it 'is sortable' do
location1 = RubyCritic::Location.new('./foo', 42)
location2 = RubyCritic::Location.new('./bar', 23)
location3 = RubyCritic::Location.new('./bar', 16)
smell1 = RubyCri... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/core/analysed_module_test.rb | test/lib/rubycritic/core/analysed_module_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'rubycritic/core/analysed_module'
require 'rubycritic/core/smell'
describe RubyCritic::AnalysedModule do
describe 'attribute readers' do
before do
@name = 'Foo'
@pathname = Pathname.new('foo.rb')
@smells = []
@churn = 1
@c... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/core/smell_test.rb | test/lib/rubycritic/core/smell_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'rubycritic/core/smell'
describe RubyCritic::Smell do
describe 'attribute readers' do
before do
@locations = [RubyCritic::Location.new('./foo', '42')]
@context = '#bar'
@message = 'This smells'
@score = 0
@type = :complexi... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/core/analysed_modules_collection_test.rb | test/lib/rubycritic/core/analysed_modules_collection_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'rubycritic/core/analysed_modules_collection'
describe RubyCritic::AnalysedModulesCollection do
subject { RubyCritic::AnalysedModulesCollection.new(paths) }
before do
RubyCritic::Config.stubs(:ruby_extensions).returns(%w[.rb])
end
describe '.ne... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/core/location_test.rb | test/lib/rubycritic/core/location_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'rubycritic/core/location'
describe RubyCritic::Location do
describe 'attribute readers' do
before do
@path = './foo.rb'
@line = '42'
@location = RubyCritic::Location.new(@path, @line)
end
it 'has a pathname' do
_(@loca... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/analysers/churn_test.rb | test/lib/rubycritic/analysers/churn_test.rb | # frozen_string_literal: true
require 'analysers_test_helper'
require 'rubycritic/analysers/churn'
require 'rubycritic/source_control_systems/base'
describe RubyCritic::Analyser::Churn do
context 'when analysing a file' do
before do
@analysed_module = AnalysedModuleDouble.new(path: 'path_to_some_file.rb')... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/analysers/complexity_test.rb | test/lib/rubycritic/analysers/complexity_test.rb | # frozen_string_literal: true
require 'analysers_test_helper'
require 'rubycritic/analysers/complexity'
describe RubyCritic::Analyser::Complexity do
context 'when analysing a file' do
before do
@analysed_module = AnalysedModuleDouble.new(path: 'test/samples/flog/complex.rb', smells: [])
analysed_mod... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/analysers/coverage_test.rb | test/lib/rubycritic/analysers/coverage_test.rb | # frozen_string_literal: true
require 'analysers_test_helper'
require 'rubycritic/analysers/coverage'
require 'rubycritic/source_control_systems/base'
require 'fakefs_helper'
describe RubyCritic::Analyser::Coverage do
describe '#run' do
let(:simplecov_version_dir) do
if Gem.loaded_specs['simplecov'].versi... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/analysers/helpers/modules_locator_test.rb | test/lib/rubycritic/analysers/helpers/modules_locator_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'rubycritic/analysers/helpers/modules_locator'
require 'rubycritic/core/analysed_module'
require 'pathname'
describe RubyCritic::ModulesLocator do
describe '#names' do
context 'when a file contains Ruby code' do
it 'returns the names of all the c... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/analysers/helpers/methods_counter_test.rb | test/lib/rubycritic/analysers/helpers/methods_counter_test.rb | # frozen_string_literal: true
require 'analysers_test_helper'
require 'rubycritic/analysers/helpers/methods_counter'
describe RubyCritic::MethodsCounter do
describe '#count' do
context 'when a file contains Ruby code' do
it 'calculates the number of methods' do
analysed_module = AnalysedModuleDoub... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/analysers/smells/flog_test.rb | test/lib/rubycritic/analysers/smells/flog_test.rb | # frozen_string_literal: true
require 'analysers_test_helper'
require 'rubycritic/analysers/smells/flog'
describe RubyCritic::Analyser::FlogSmells do
context 'when analysing a complex file' do
before do
@analysed_module = AnalysedModuleDouble.new(path: 'test/samples/flog/smelly.rb', smells: [])
anal... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/analysers/smells/flay_test.rb | test/lib/rubycritic/analysers/smells/flay_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'rubycritic/analysers/smells/flay'
require 'rubycritic/core/analysed_module'
require 'pathname'
describe RubyCritic::Analyser::FlaySmells do
context 'when analysing a bunch of files with duplicate code' do
before do
@analysed_modules = [
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/test/lib/rubycritic/analysers/smells/reek_test.rb | test/lib/rubycritic/analysers/smells/reek_test.rb | # frozen_string_literal: true
require 'analysers_test_helper'
require 'rubycritic/analysers/smells/reek'
describe RubyCritic::Analyser::ReekSmells do
context 'when analysing a smelly file' do
before do
# Reset Reek configuration between tests
# Config is cached and can leak between tests
RubyC... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/features/support/env.rb | features/support/env.rb | # frozen_string_literal: true
require_relative '../../lib/rubycritic'
require_relative '../../lib/rubycritic/cli/application'
require_relative '../../lib/rubycritic/commands/status_reporter'
require 'aruba/cucumber'
require 'minitest/spec'
#
# Provides runner methods used in the cucumber steps.
#
class RubyCriticWorl... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/features/step_definitions/sample_file_steps.rb | features/step_definitions/sample_file_steps.rb | # frozen_string_literal: true
Given(/^the smelly file 'smelly.rb'/) do
contents = <<~RUBY
class AllTheMethods
def method_missing(method, *args, &block)
message = "I"
eval "message = ' did not'"
eval "message << ' exist,'"
eval "message << ' but now'"
eval "message <<... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/features/step_definitions/rake_task_steps.rb | features/step_definitions/rake_task_steps.rb | # frozen_string_literal: true
When(/^I run rake (\w*) with:$/) do |name, task_def|
rake(name, task_def)
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/features/step_definitions/rubycritic_steps.rb | features/step_definitions/rubycritic_steps.rb | # frozen_string_literal: true
When(/^I run rubycritic (.*)$/) do |args|
rubycritic(args)
end
Then(/^the exit status indicates an error$/) do
expect(last_command_started).to have_exit_status(RubyCritic::Command::StatusReporter::SCORE_BELOW_MINIMUM)
end
Then(/^the exit status indicates a success$/) do
expect(las... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic.rb | lib/rubycritic.rb | # frozen_string_literal: true
require 'rubycritic/command_factory'
module RubyCritic
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysis_summary.rb | lib/rubycritic/analysis_summary.rb | # frozen_string_literal: true
module RubyCritic
class AnalysisSummary
def self.generate(analysed_modules)
new(analysed_modules).generate
end
def initialize(analysed_modules)
@analysed_modules = analysed_modules
end
def generate
%w[A B C D F].each_with_object({}) do |rating, su... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/version.rb | lib/rubycritic/version.rb | # frozen_string_literal: true
module RubyCritic
VERSION = '4.12.0'
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/command_factory.rb | lib/rubycritic/command_factory.rb | # frozen_string_literal: true
require 'rubycritic/configuration'
module RubyCritic
class CommandFactory
COMMAND_CLASS_MODES = %i[version help ci compare default].freeze
def self.create(options = {})
Config.set(options)
command_class(Config.mode).new(options)
end
def self.command_class(... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/browser.rb | lib/rubycritic/browser.rb | # frozen_string_literal: true
require 'launchy'
module RubyCritic
class Browser
attr_reader :report_path
def initialize(report_path)
@report_path = report_path
end
def open
Launchy.open(report_path) do |exception|
puts "Attempted to open #{report_path} and failed because #{exce... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/rake_task.rb | lib/rubycritic/rake_task.rb | # frozen_string_literal: true
require 'rake'
require 'rake/tasklib'
require 'English'
require 'rubycritic/cli/application'
module RubyCritic
#
# A rake task that runs RubyCritic on a set of source files.
#
# This will create a task that can be run with:
#
# rake rubycritic
#
# Example:
#
# req... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/serializer.rb | lib/rubycritic/serializer.rb | # frozen_string_literal: true
require 'fileutils'
module RubyCritic
class Serializer
def initialize(file)
@file = file
end
def load
Marshal.load(File.binread(@file))
end
def dump(content)
create_file_directory
File.open(@file, 'w+') do |file|
Marshal.dump(conten... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/smells_status_setter.rb | lib/rubycritic/smells_status_setter.rb | # frozen_string_literal: true
module RubyCritic
module SmellsStatusSetter
def self.set(smells_before, smells_now)
old_smells = smells_now & smells_before
set_status(old_smells, :old)
new_smells = smells_now - smells_before
set_status(new_smells, :new)
end
def self.set_status(smel... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers_runner.rb | lib/rubycritic/analysers_runner.rb | # frozen_string_literal: true
require 'rubycritic/core/analysed_modules_collection'
require 'rubycritic/analysers/smells/flay'
require 'rubycritic/analysers/smells/flog'
require 'rubycritic/analysers/smells/reek'
require 'rubycritic/analysers/complexity'
require 'rubycritic/analysers/churn'
require 'rubycritic/analyse... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/revision_comparator.rb | lib/rubycritic/revision_comparator.rb | # frozen_string_literal: true
require 'rubycritic/serializer'
require 'rubycritic/analysers_runner'
require 'rubycritic/smells_status_setter'
require 'rubycritic/version'
require 'digest/md5'
module RubyCritic
class RevisionComparator
SNAPSHOTS_DIR_NAME = 'snapshots'.freeze
def initialize(paths)
@pat... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/configuration.rb | lib/rubycritic/configuration.rb | # frozen_string_literal: true
require 'rubycritic/source_control_systems/base'
module RubyCritic
class Configuration
attr_reader :root
attr_accessor :source_control_system, :mode, :formats, :formatters, :deduplicate_symlinks,
:suppress_ratings, :open_with, :no_browser, :base_branch, :cover... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/source_locator.rb | lib/rubycritic/source_locator.rb | # frozen_string_literal: true
require 'pathname'
require 'rubycritic/configuration'
module RubyCritic
class SourceLocator
RUBY_EXTENSION = '.rb'.freeze
RUBY_FILES = File.join('**', "*#{RUBY_EXTENSION}")
RUBY_SHEBANG = '#!/usr/bin/env ruby'.freeze
def initialize(paths)
@initial_paths = Array(p... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/reporter.rb | lib/rubycritic/reporter.rb | # frozen_string_literal: true
module RubyCritic
module Reporter
REPORT_GENERATOR_CLASS_FORMATS = %i[json console lint].freeze
def self.generate_report(analysed_modules)
RubyCritic::Config.formats.uniq.each do |format|
report_generator_class(format).new(analysed_modules).generate_report
e... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/colorize.rb | lib/rubycritic/colorize.rb | # frozen_string_literal: true
module RubyCritic
module Colorize
def colorize(text, color_code)
"\e[#{color_code}m#{text}\e[0m"
end
def red(text)
colorize(text, 31)
end
def green(text)
colorize(text, 32)
end
end
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/commands/ci.rb | lib/rubycritic/commands/ci.rb | # frozen_string_literal: true
require 'rubycritic/source_control_systems/base'
require 'rubycritic/analysers_runner'
require 'rubycritic/reporter'
require 'rubycritic/commands/default'
require 'rubycritic/commands/compare'
module RubyCritic
module Command
class Ci < Compare
end
end
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/commands/version.rb | lib/rubycritic/commands/version.rb | # frozen_string_literal: true
require 'rubycritic/version'
require 'rubycritic/commands/base'
module RubyCritic
module Command
class Version < Base
attr_reader :status_reporter
def execute
puts "RubyCritic #{VERSION}"
status_reporter
end
end
end
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/commands/default.rb | lib/rubycritic/commands/default.rb | # frozen_string_literal: true
require 'rubycritic/source_control_systems/base'
require 'rubycritic/analysers_runner'
require 'rubycritic/revision_comparator'
require 'rubycritic/reporter'
require 'rubycritic/commands/base'
module RubyCritic
module Command
class Default < Base
def initialize(options)
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/commands/help.rb | lib/rubycritic/commands/help.rb | # frozen_string_literal: true
require 'rubycritic/commands/base'
module RubyCritic
module Command
class Help < Base
def execute
puts options[:help_text]
status_reporter
end
private
attr_reader :options, :status_reporter
end
end
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/commands/base.rb | lib/rubycritic/commands/base.rb | # frozen_string_literal: true
require 'rubycritic/commands/status_reporter'
module RubyCritic
module Command
class Base
def initialize(options)
@options = options
@status_reporter = RubyCritic::Command::StatusReporter.new(@options)
end
def execute
raise NotImplementedE... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/commands/compare.rb | lib/rubycritic/commands/compare.rb | # frozen_string_literal: true
require 'rubycritic/source_control_systems/base'
require 'rubycritic/analysers_runner'
require 'rubycritic/revision_comparator'
require 'rubycritic/reporter'
require 'rubycritic/commands/base'
require 'rubycritic/commands/default'
require 'rubycritic/commands/utils/build_number_file'
mod... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/commands/status_reporter.rb | lib/rubycritic/commands/status_reporter.rb | # frozen_string_literal: true
module RubyCritic
module Command
class StatusReporter
attr_reader :status, :status_message, :score
SUCCESS = 0
SCORE_BELOW_MINIMUM = 1
def initialize(options)
@options = options
@status = SUCCESS
end
def score=(input_score)
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/commands/utils/build_number_file.rb | lib/rubycritic/commands/utils/build_number_file.rb | # frozen_string_literal: true
module RubyCritic
module Command
module Utils
class BuildNumberFile
attr_reader :file, :build_number
def initialize
open_build_number_file
end
# keep track of the number of builds and
# use this build number to create separat... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/json_report.rb | lib/rubycritic/generators/json_report.rb | # frozen_string_literal: true
require 'rubycritic/generators/json/simple'
module RubyCritic
module Generator
class JsonReport
def initialize(analysed_modules)
@analysed_modules = analysed_modules
end
def generate_report
FileUtils.mkdir_p(generator.file_directory)
File.... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html_report.rb | lib/rubycritic/generators/html_report.rb | # frozen_string_literal: true
require 'fileutils'
require 'rubycritic/configuration'
require 'rubycritic/generators/html/overview'
require 'rubycritic/generators/html/smells_index'
require 'rubycritic/generators/html/code_index'
require 'rubycritic/generators/html/simple_cov_index'
require 'rubycritic/generators/html/... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/console_report.rb | lib/rubycritic/generators/console_report.rb | # frozen_string_literal: true
require 'rubycritic/generators/text/list'
module RubyCritic
module Generator
class ConsoleReport
def initialize(analysed_modules)
@analysed_modules = analysed_modules
end
def generate_report
reports = @analysed_modules.sort.map do |mod|
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/lint_report.rb | lib/rubycritic/generators/lint_report.rb | # frozen_string_literal: true
require 'rubycritic/generators/text/lint'
module RubyCritic
module Generator
class LintReport
def initialize(analysed_modules)
@analysed_modules = analysed_modules
end
def generate_report
FileUtils.mkdir_p(generator.file_directory)
File.wr... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/json/simple.rb | lib/rubycritic/generators/json/simple.rb | # frozen_string_literal: true
require 'json'
require 'rubycritic/version'
require 'pathname'
module RubyCritic
module Generator
module Json
class Simple
def initialize(analysed_modules)
@analysed_modules = analysed_modules
end
FILE_NAME = 'report.json'.freeze
de... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html/code_file.rb | lib/rubycritic/generators/html/code_file.rb | # frozen_string_literal: true
require 'rubycritic/generators/html/base'
require 'rubycritic/generators/html/line'
module RubyCritic
module Generator
module Html
class CodeFile < Base
LINE_NUMBER_OFFSET = 1
TEMPLATE = erb_template('code_file.html.erb')
def initialize(analysed_modul... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html/simple_cov_index.rb | lib/rubycritic/generators/html/simple_cov_index.rb | # frozen_string_literal: true
require 'rubycritic/generators/html/base'
module RubyCritic
module Generator
module Html
class SimpleCovIndex < Base
TEMPLATE = erb_template('simple_cov_index.html.erb')
def initialize(analysed_modules)
@analysed_modules = sorted(filtered(analysed_m... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html/view_helpers.rb | lib/rubycritic/generators/html/view_helpers.rb | # frozen_string_literal: true
module RubyCritic
module ViewHelpers
def timeago_tag(time)
"<time class='js-timeago' datetime='#{time}'>#{time}</time>"
end
def asset_path(file)
relative_path("assets/#{file}")
end
def file_path(file)
relative_path(file)
end
def smell_loc... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html/overview.rb | lib/rubycritic/generators/html/overview.rb | # frozen_string_literal: true
require 'rubycritic/generators/html/base'
require 'rubycritic/generators/html/turbulence'
require 'rubycritic/analysis_summary'
module RubyCritic
module Generator
module Html
class Overview < Base
TEMPLATE = erb_template('overview.html.erb')
def initialize(an... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html/turbulence.rb | lib/rubycritic/generators/html/turbulence.rb | # frozen_string_literal: true
require 'json'
module RubyCritic
module Turbulence
def self.data(analysed_modules)
analysed_modules.map do |analysed_module|
{
name: analysed_module.name,
x: analysed_module.churn,
y: analysed_module.complexity,
rating: analysed_... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html/line.rb | lib/rubycritic/generators/html/line.rb | # frozen_string_literal: true
require 'cgi'
require 'rubycritic/generators/html/base'
module RubyCritic
module Generator
module Html
class Line < Base
NORMAL_TEMPLATE = erb_template('line.html.erb')
SMELLY_TEMPLATE = erb_template('smelly_line.html.erb')
attr_reader :file_directory... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html/smells_index.rb | lib/rubycritic/generators/html/smells_index.rb | # frozen_string_literal: true
require 'rubycritic/generators/html/base'
module RubyCritic
module Generator
module Html
class SmellsIndex < Base
TEMPLATE = erb_template('smells_index.html.erb')
def initialize(analysed_modules)
@smells = analysed_modules.flat_map(&:smells).uniq
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html/base.rb | lib/rubycritic/generators/html/base.rb | # frozen_string_literal: true
require 'erb'
require 'pathname'
require 'rubycritic/generators/html/view_helpers'
module RubyCritic
module Generator
module Html
class Base
def self.erb_template(template_path)
ERB.new(File.read(File.join(TEMPLATES_DIR, template_path)))
end
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/html/code_index.rb | lib/rubycritic/generators/html/code_index.rb | # frozen_string_literal: true
require 'rubycritic/generators/html/base'
module RubyCritic
module Generator
module Html
class CodeIndex < Base
TEMPLATE = erb_template('code_index.html.erb')
def initialize(analysed_modules)
@analysed_modules = analysed_modules
set_header... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/text/lint.rb | lib/rubycritic/generators/text/lint.rb | # frozen_string_literal: true
require 'erb'
module RubyCritic
module Generator
module Text
class Lint
class << self
TEMPLATE_PATH = File.expand_path('templates/lint.erb', __dir__)
FILE_NAME = 'lint.txt'.freeze
def file_directory
@file_directory ||= Pathnam... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/generators/text/list.rb | lib/rubycritic/generators/text/list.rb | # frozen_string_literal: true
require 'rainbow'
module RubyCritic
module Generator
module Text
class List
class << self
TEMPLATE_PATH = File.expand_path('templates/list.erb', __dir__)
def erb_template
@erb_template ||= ERB.new(File.read(TEMPLATE_PATH), trim_mode: '... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/source_control_systems/mercurial.rb | lib/rubycritic/source_control_systems/mercurial.rb | # frozen_string_literal: true
module RubyCritic
module SourceControlSystem
class Mercurial < Base
register_system
def self.supported?
hg_verify = `hg verify 2>&1`
hg_verify && $CHILD_STATUS.success?
end
def self.to_s
'Mercurial'
end
def revisions_cou... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/source_control_systems/perforce.rb | lib/rubycritic/source_control_systems/perforce.rb | # frozen_string_literal: true
require 'date'
module RubyCritic
module SourceControlSystem
PERFORCE_FSTAT_OPTS = '-F "clientFile=*.rb" -T clientFile,headRev,headTime,headChange,action'.freeze
PerforceStats = Struct.new(:filename, :revision, :last_commit, :opened?, :head)
class Perforce < Base
regi... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/source_control_systems/base.rb | lib/rubycritic/source_control_systems/base.rb | # frozen_string_literal: true
require 'English'
require 'shellwords'
module RubyCritic
module SourceControlSystem
class Base
@@systems = [] # rubocop:disable Style/ClassVars
def self.register_system
@@systems << self
end
def self.systems
@@systems
end
def s... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/source_control_systems/double.rb | lib/rubycritic/source_control_systems/double.rb | # frozen_string_literal: true
module RubyCritic
module SourceControlSystem
class Double < Base
def revisions_count(_path)
0
end
def date_of_last_commit(_path)
nil
end
def revision?
false
end
end
end
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/source_control_systems/git.rb | lib/rubycritic/source_control_systems/git.rb | # frozen_string_literal: true
require 'tty/which'
require 'rubycritic/source_control_systems/git/churn'
module RubyCritic
module SourceControlSystem
class Git < Base
register_system
GIT_EXECUTABLE = TTY::Which.which('git')
def self.git(arg)
if Gem.win_platform?
`\"#{GIT_EXEC... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/source_control_systems/git/churn.rb | lib/rubycritic/source_control_systems/git/churn.rb | # frozen_string_literal: true
module RubyCritic
module SourceControlSystem
class Git < Base
Stats = Struct.new(:count, :date)
class Renames
def initialize
@data = {}
end
def renamed(from, to)
current = current(to)
@data[from] = current
e... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/core/analysed_modules_collection.rb | lib/rubycritic/core/analysed_modules_collection.rb | # frozen_string_literal: true
require 'rubycritic/source_locator'
require 'rubycritic/core/analysed_module'
module RubyCritic
class AnalysedModulesCollection
include Enumerable
# Limit used to prevent very bad modules to have excessive impact in the
# overall result. See #limited_cost_for
COST_LIMI... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/core/smell.rb | lib/rubycritic/core/smell.rb | # frozen_string_literal: true
require 'virtus'
require 'rubycritic/core/location'
module RubyCritic
class Smell
include Virtus.model
attribute :context
attribute :cost
attribute :locations, Array, default: []
attribute :message
attribute :score
attribute :status, Symbol, default: :new
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/core/location.rb | lib/rubycritic/core/location.rb | # frozen_string_literal: true
require 'pathname'
module RubyCritic
class Location
attr_reader :pathname, :line
def initialize(path, line)
@pathname = Pathname.new(path)
@line = line.to_i
end
def file_name
@pathname.basename.sub_ext('').to_s
end
def to_s
"#{pathname... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/core/rating.rb | lib/rubycritic/core/rating.rb | # frozen_string_literal: true
module RubyCritic
class Rating
def self.from_cost(cost)
if cost <= 2 then new('A')
elsif cost <= 4 then new('B')
elsif cost <= 8 then new('C')
elsif cost <= 16 then new('D')
else
new('F')
end
end
def initialize(letter)
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/core/analysed_module.rb | lib/rubycritic/core/analysed_module.rb | # frozen_string_literal: true
require 'virtus'
require 'rubycritic/core/rating'
module RubyCritic
class AnalysedModule
include Virtus.model
# Complexity is reduced by a factor of 25 when calculating cost
COMPLEXITY_FACTOR = 25.0
attribute :coverage, Float, default: 0.0
attribute :name
attr... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/attributes.rb | lib/rubycritic/analysers/attributes.rb | # frozen_string_literal: true
require 'rubycritic/analysers/helpers/methods_counter'
require 'rubycritic/analysers/helpers/modules_locator'
require 'rubycritic/colorize'
module RubyCritic
module Analyser
class Attributes
include Colorize
def initialize(analysed_modules)
@analysed_modules = ... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/complexity.rb | lib/rubycritic/analysers/complexity.rb | # frozen_string_literal: true
require 'rubycritic/analysers/helpers/flog'
require 'rubycritic/colorize'
module RubyCritic
module Analyser
class Complexity
include Colorize
def initialize(analysed_modules)
@flog = Flog.new
@analysed_modules = analysed_modules
end
def run... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/coverage.rb | lib/rubycritic/analysers/coverage.rb | # frozen_string_literal: true
require 'rubycritic/colorize'
require 'json'
require 'simplecov'
module RubyCritic
module Analyser
class Coverage
include Colorize
RESULTSET_FILENAME = '.resultset.json'
def initialize(analysed_modules)
@analysed_modules = analysed_modules
@resul... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/churn.rb | lib/rubycritic/analysers/churn.rb | # frozen_string_literal: true
require 'rubycritic/colorize'
module RubyCritic
module Analyser
class Churn
include Colorize
attr_writer :source_control_system
def initialize(analysed_modules)
@analysed_modules = analysed_modules
@source_control_system = Config.source_control_s... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/helpers/modules_locator.rb | lib/rubycritic/analysers/helpers/modules_locator.rb | # frozen_string_literal: true
require 'rubycritic/analysers/helpers/parser'
module RubyCritic
class ModulesLocator
def initialize(analysed_module)
@analysed_module = analysed_module
end
def first_name
name_from_path.first
end
def names
names = node.module_names
if names... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/helpers/ast_node.rb | lib/rubycritic/analysers/helpers/ast_node.rb | # frozen_string_literal: true
module Parser
module AST
class Node
MODULE_TYPES = %i[module class].freeze
def count_nodes_of_type(*types)
count = 0
recursive_children do |child|
count += 1 if types.include?(child.type)
end
count
end
def recursive... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/helpers/reek.rb | lib/rubycritic/analysers/helpers/reek.rb | # frozen_string_literal: true
require 'reek'
module RubyCritic
class Reek < ::Reek::Examiner
def self.configuration
@configuration ||= ::Reek::Configuration::AppConfiguration.from_default_path
end
def initialize(analysed_module)
super(analysed_module, configuration: self.class.configuration... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/helpers/parser.rb | lib/rubycritic/analysers/helpers/parser.rb | # frozen_string_literal: true
module RubyCritic
module Parser
def self.parse(content)
parser = parser_class
require 'rubycritic/analysers/helpers/ast_node'
parser.parse(content) || AST::EmptyNode.new
rescue ::Parser::SyntaxError
AST::EmptyNode.new
end
def self.parser_class
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/helpers/methods_counter.rb | lib/rubycritic/analysers/helpers/methods_counter.rb | # frozen_string_literal: true
require 'rubycritic/analysers/helpers/parser'
module RubyCritic
class MethodsCounter
def initialize(analysed_module)
@analysed_module = analysed_module
end
def count
node.count_nodes_of_type(:def, :defs)
end
private
def node
Parser.parse(con... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/helpers/flay.rb | lib/rubycritic/analysers/helpers/flay.rb | # frozen_string_literal: true
require 'flay'
module RubyCritic
class Flay < ::Flay
def initialize(paths)
super()
paths = PathExpander.new([], '').filter_files(paths, DEFAULT_IGNORE)
process(*paths)
analyze
end
end
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/helpers/flog.rb | lib/rubycritic/analysers/helpers/flog.rb | # frozen_string_literal: true
require 'flog'
module RubyCritic
class Flog < ::Flog
DEFAULT_OPTIONS = {
all: true,
continue: true,
methods: true
}.freeze
def initialize
super(DEFAULT_OPTIONS.clone(freeze: false))
end
end
end
| ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/smells/reek.rb | lib/rubycritic/analysers/smells/reek.rb | # frozen_string_literal: true
require 'rubycritic/analysers/helpers/reek'
require 'rubycritic/core/smell'
require 'rubycritic/colorize'
module RubyCritic
module Analyser
class ReekSmells
include Colorize
def initialize(analysed_modules)
@analysed_modules = analysed_modules.reject { Reek.con... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/smells/flay.rb | lib/rubycritic/analysers/smells/flay.rb | # frozen_string_literal: true
require 'rubycritic/analysers/helpers/flay'
require 'rubycritic/core/smell'
require 'rubycritic/colorize'
module RubyCritic
module Analyser
class FlaySmells
include Colorize
def initialize(analysed_modules)
@analysed_modules = paths_to_analysed_modules(analysed... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/analysers/smells/flog.rb | lib/rubycritic/analysers/smells/flog.rb | # frozen_string_literal: true
require 'rubycritic/analysers/helpers/flog'
require 'rubycritic/core/smell'
require 'rubycritic/colorize'
module RubyCritic
module Analyser
class FlogSmells
include Colorize
HIGH_COMPLEXITY_SCORE_THRESHOLD = 25
VERY_HIGH_COMPLEXITY_SCORE_THRESHOLD = 60
def... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/cli/application.rb | lib/rubycritic/cli/application.rb | # frozen_string_literal: true
require 'rubycritic'
require 'rubycritic/browser'
require 'rubycritic/cli/options'
require 'rubycritic/command_factory'
module RubyCritic
module Cli
class Application
STATUS_SUCCESS = 0
STATUS_ERROR = 1
def initialize(argv)
@options = Options.new(argv)
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/cli/options.rb | lib/rubycritic/cli/options.rb | # frozen_string_literal: true
require 'rubycritic/cli/options/argv'
require 'rubycritic/cli/options/file'
module RubyCritic
module Cli
class Options
attr_reader :argv_options, :file_options
def initialize(argv)
@argv_options = Argv.new(argv)
@file_options = File.new
end
... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/cli/options/file.rb | lib/rubycritic/cli/options/file.rb | # frozen_string_literal: true
require 'yaml'
module RubyCritic
module Cli
class Options
class File
attr_reader :filename, :options
def initialize(filename = './.rubycritic.yml')
@filename = filename
@options = {}
end
def parse
@options = YAML... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
whitesmith/rubycritic | https://github.com/whitesmith/rubycritic/blob/e072f19a6721889575c471e15b15e63cff7a7276/lib/rubycritic/cli/options/argv.rb | lib/rubycritic/cli/options/argv.rb | # frozen_string_literal: true
require 'optparse'
module RubyCritic
module Cli
class Options
# rubocop:disable Metrics/ClassLength
class Argv
def initialize(argv)
@argv = argv
self.parser = OptionParser.new
end
# rubocop:disable Metrics/MethodLength,Metric... | ruby | MIT | e072f19a6721889575c471e15b15e63cff7a7276 | 2026-01-04T15:50:21.177610Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/app/controllers/view_components_controller.rb | app/controllers/view_components_controller.rb | # frozen_string_literal: true
require "rails/application_controller"
class ViewComponentsController < Rails::ApplicationController # :nodoc:
include ViewComponent::PreviewActions
end
| ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/app/controllers/view_components_system_test_controller.rb | app/controllers/view_components_system_test_controller.rb | # frozen_string_literal: true
class ViewComponentsSystemTestController < ActionController::Base # :nodoc:
if Rails.env.test?
before_action :validate_file_path
def self.temp_dir
@_tmpdir ||= FileUtils.mkdir_p("./tmp/view_components/").first
end
def system_test_entrypoint
render file: @pa... | ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/app/controllers/concerns/view_component/preview_actions.rb | app/controllers/concerns/view_component/preview_actions.rb | # frozen_string_literal: true
module ViewComponent
module PreviewActions
extend ActiveSupport::Concern
included do
prepend_view_path File.expand_path("../../../views", __dir__)
around_action :set_locale, only: :previews
before_action :require_local!, unless: :previews_enabled?
cont... | ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/docs_rake_task_test.rb | test/docs_rake_task_test.rb | # frozen_string_literal: true
require "test_helper"
class DocsRakeTaskTest < ActiveSupport::TestCase
def test_rake_task
load "Rakefile"
assert_nothing_raised do
Rake::Task["docs:build"].invoke
end
Rake::Task.clear
end
end
| ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/test_helper.rb | test/test_helper.rb | # frozen_string_literal: true
require "allocation_stats"
require "rails/version"
require "bundler/setup"
require "pathname"
require "minitest/autorun"
if ENV["RAISE_ON_WARNING"]
module Warning
PROJECT_ROOT = File.expand_path("..", __dir__).freeze
def self.warn(message)
called_by = caller_locations(1,... | ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/sandbox/app/helpers/message_helper.rb | test/sandbox/app/helpers/message_helper.rb | # frozen_string_literal: true
module MessageHelper
def message
"Hello helper method"
end
end
| ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/sandbox/app/helpers/partial_helper.rb | test/sandbox/app/helpers/partial_helper.rb | # frozen_string_literal: true
module PartialHelper
module State
def self.calls
@_calls || 0
end
def self.reset
@_calls = 0
end
def self.expensive_query
@_calls ||= 0
@_calls += 1
end
end
def expensive_message
return @_foo if defined?(@_foo)
@_foo = Stat... | ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/sandbox/app/helpers/content_tag_helper.rb | test/sandbox/app/helpers/content_tag_helper.rb | # frozen_string_literal: true
module ContentTagHelper
def my_helper_method(options, &block)
content_tag(:div, options, &block)
end
end
| ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/sandbox/app/controllers/layouts_controller.rb | test/sandbox/app/controllers/layouts_controller.rb | # frozen_string_literal: true
# Tests for render with/without layouts
class LayoutsController < ApplicationController
layout "global_for_action", only: :global_for_action
def default
render(MyComponent.new)
end
def global_for_action
render(MyComponent.new)
end
def explicit_in_action
render(M... | ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/sandbox/app/controllers/default_form_builder_controller.rb | test/sandbox/app/controllers/default_form_builder_controller.rb | # frozen_string_literal: true
class DefaultFormBuilderController < ActionController::Base
class OtherFormBuilder < ActionView::Helpers::FormBuilder
def text_field(*)
"changed by default form builder"
end
end
default_form_builder OtherFormBuilder
end
| ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/sandbox/app/controllers/custom_test_controller_controller.rb | test/sandbox/app/controllers/custom_test_controller_controller.rb | # frozen_string_literal: true
class CustomTestControllerController < ActionController::Base
helper_method :foo
private
def foo
"foo"
end
end
| ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/sandbox/app/controllers/my_preview_controller.rb | test/sandbox/app/controllers/my_preview_controller.rb | # frozen_string_literal: true
class MyPreviewController < ViewComponentsController
def index
render plain: "Custom controller"
end
end
| ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/sandbox/app/controllers/application_controller.rb | test/sandbox/app/controllers/application_controller.rb | # frozen_string_literal: true
class ApplicationController < ActionController::Base
end
| ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
ViewComponent/view_component | https://github.com/ViewComponent/view_component/blob/48da443d2b0df16a981b7ec0cc4c6cf0a51114fb/test/sandbox/app/controllers/integration_examples_controller.rb | test/sandbox/app/controllers/integration_examples_controller.rb | # frozen_string_literal: true
class IntegrationExamplesController < ActionController::Base
layout false
def variants
request.variant = params[:variant].to_sym if params[:variant]
end
def controller_inline
render(ControllerInlineComponent.new(message: "bar"))
end
def controller_inline_with_block
... | ruby | MIT | 48da443d2b0df16a981b7ec0cc4c6cf0a51114fb | 2026-01-04T15:50:14.216895Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.