source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/isolated_environment_spec.rb
Ruby
mit
12,856
master
1,366
# frozen_string_literal: true RSpec.describe 'isolated environment', :isolated_environment, type: :feature do include_context 'cli spec behavior' let(:cli) { RuboCop::CLI.new } # Configuration files above the work directory shall not disturb the # tests. This is especially important on Windows where the temp...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cli_spec_behavior.rb
Ruby
mit
12,856
master
971
# frozen_string_literal: true RSpec.shared_context 'cli spec behavior' do include_context 'mock console output' include FileHelper def abs(path) File.expand_path(path) end before do RuboCop::ConfigLoader.debug = false RuboCop::ConfigLoader.default_configuration = nil # OPTIMIZE: Makes the...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/multiline_literal_brace_layout_examples.rb
Ruby
mit
12,856
master
10,253
# frozen_string_literal: true RSpec.shared_examples 'multiline literal brace layout' do include MultilineLiteralBraceHelper let(:prefix) { '' } # A prefix before the opening brace. let(:suffix) { '' } # A suffix for the line after the closing brace. let(:a) { 'a' } # The first element. let(:b) { 'b' } # The...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/mcp_helper.rb
Ruby
mit
12,856
master
678
# frozen_string_literal: true require 'rubocop/mcp/server' module MCPHelper def run_server_on_requests(*requests) stdin = StringIO.new(requests.map(&:to_json).join) stdout = StringIO.new stderr = StringIO.new RuboCop::Server::Helper.redirect(stdin: stdin, stdout: stdout, stderr: stderr) do co...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/strict_warnings.rb
Ruby
mit
12,856
master
2,226
# frozen_string_literal: true # NOTE: Prevents the cause from being obscured by `uninitialized constant StrictWarnings::StringIO` # when there is a warning or syntax error in the product code. require 'stringio' # Ensure that RuboCop runs warning-free. This hooks into Ruby's `warn` # method and raises when an unexpec...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/file_helper.rb
Ruby
mit
12,856
master
1,591
# frozen_string_literal: true require 'fileutils' module FileHelper # rubocop:disable Metrics/MethodLength def create_file(file_path, content, retain_line_terminators: false) file_path = File.expand_path(file_path) # On Windows, when a file is opened in 'w' mode, LF line terminators (`\n`) # are auto...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/lsp_helper.rb
Ruby
mit
12,856
master
765
# frozen_string_literal: true require 'rubocop/lsp/server' module LSPHelper def run_server_on_requests(*requests) stdin = StringIO.new(requests.map { |request| to_jsonrpc(request) }.join) RuboCop::Server::Helper.redirect(stdin: stdin) do config_store = RuboCop::ConfigStore.new RuboCop::LSP::Se...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/suppress_pending_warning.rb
Ruby
mit
12,856
master
399
# frozen_string_literal: true # # This is a file that supports testing. An open class has been applied to # `RuboCop::PendingCopsReporter.warn_on_pending_cops` to suppress pending cop # warnings during testing. # module RuboCop class PendingCopsReporter class << self remove_method :warn_on_pending_cops ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/alignment_examples.rb
Ruby
mit
12,856
master
1,406
# frozen_string_literal: true # `cop` and `source` must be declared with #let. RSpec.shared_examples 'misaligned' do |annotated_source, used_style| config_to_allow_offenses = if used_style { 'EnforcedStyleAlignWith' => used_style.to_s } else ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/condition_modifier_cop.rb
Ruby
mit
12,856
master
5,966
# frozen_string_literal: true RSpec.shared_examples 'condition modifier cop' do |keyword, extra_message = nil| let(:other_cops) { { 'Layout/LineLength' => { 'Max' => 80 } } } context "for a multiline '#{keyword}'" do it 'accepts it if single line would not fit on one line' do # This statement is one cha...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/multiline_literal_brace_helper.rb
Ruby
mit
12,856
master
1,318
# frozen_string_literal: true module MultilineLiteralBraceHelper # Construct the source code for the braces. For instance, for an array # the `open` brace would be `[` and the `close` brace would be `]`, so # you could construct the following: # # braces(true, 'a', 'b', 'c', false) # # [ # line b...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/empty_lines_around_body_shared_examples.rb
Ruby
mit
12,856
master
10,491
# frozen_string_literal: true RSpec.shared_examples 'empty_lines_around_class_or_module_body' do |type| context 'when EnforcedStyle is empty_lines_special' do let(:cop_config) { { 'EnforcedStyle' => 'empty_lines_special' } } context 'when first child is a method' do it "requires blank line at the begi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/multiline_literal_brace_layout_trailing_comma_examples.rb
Ruby
mit
12,856
master
1,654
# frozen_string_literal: true RSpec.shared_examples 'multiline literal brace layout trailing comma' do let(:prefix) { '' } # A prefix before the opening brace. let(:suffix) { '' } # A suffix for the line after the closing brace. let(:a) { 'a' } # The first element. let(:b) { 'b' } # The second element. cont...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/exclude_limit_helper.rb
Ruby
mit
12,856
master
736
# frozen_string_literal: true require 'tmpdir' module ExcludeLimitHelper # Reads exclude_limit values from the tmp files written by ExcludeLimit. # Returns a hash like { 'Max' => 81 } or nil if no values were written. def read_exclude_limit(cop, parameter_name = nil) if parameter_name read_exclude_lim...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/custom_matchers.rb
Ruby
mit
12,856
master
551
# frozen_string_literal: true RSpec::Matchers.define :exit_with_code do |code| supports_block_expectations actual = nil match do |block| begin block.call rescue SystemExit => e actual = e.status end actual && actual == code end failure_message do "expected block to call exi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/multiline_literal_brace_layout_method_argument_examples.rb
Ruby
mit
12,856
master
1,125
# frozen_string_literal: true RSpec.shared_examples 'multiline literal brace layout method argument' do include MultilineLiteralBraceHelper context 'when arguments to a method' do let(:prefix) { 'bar(' } let(:suffix) { ')' } context 'and a comment after the last element' do let(:b_comment) { ' ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/encoding_helper.rb
Ruby
mit
12,856
master
813
# frozen_string_literal: true # Overwrite the default internal/external encoding for the duration of a block. # Ruby discourages this by emitting a warning when modifying, these helpers exist # to suppress these warnings during tests. module EncodingHelper def with_default_internal_encoding(encoding) orig_encodi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/infinite_loop_during_autocorrect_with_change.rb
Ruby
mit
12,856
master
646
# frozen_string_literal: true module RuboCop module Cop module Test class InfiniteLoopDuringAutocorrectWithChangeCop < RuboCop::Cop::Base extend AutoCorrector def on_class(node) add_offense(node, message: 'Class must be a Module') do |corrector| corrector.replace(node...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/alignment_directive.rb
Ruby
mit
12,856
master
1,174
# frozen_string_literal: true module RuboCop module Cop module Test # This cop allows us to test the {AlignmentCorrector}. A node that is # annotated with a comment of the form `# << delta` or `# >> delta` where # `delta` is an integer will be shifted by `delta` columns in the # indicated...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/c_to_a_cop.rb
Ruby
mit
12,856
master
640
# frozen_string_literal: true module RuboCop module Cop module Test # This cop is only used to test infinite loop detection class CtoA < RuboCop::Cop::Base extend AutoCorrector def on_class(node) return unless node.loc.name.source.include?('C') add_offense(node.l...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/class_must_be_a_module_cop.rb
Ruby
mit
12,856
master
377
# frozen_string_literal: true module RuboCop module Cop module Test class ClassMustBeAModuleCop < RuboCop::Cop::Base extend AutoCorrector def on_class(node) add_offense(node, message: 'Class must be a Module') do |corrector| corrector.replace(node.loc.keyword, 'module...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/b_to_c_cop.rb
Ruby
mit
12,856
master
640
# frozen_string_literal: true module RuboCop module Cop module Test # This cop is only used to test infinite loop detection class BtoC < RuboCop::Cop::Base extend AutoCorrector def on_class(node) return unless node.loc.name.source.include?('B') add_offense(node.l...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/module_must_be_a_class_cop.rb
Ruby
mit
12,856
master
377
# frozen_string_literal: true module RuboCop module Cop module Test class ModuleMustBeAClassCop < RuboCop::Cop::Base extend AutoCorrector def on_module(node) add_offense(node, message: 'Module must be a Class') do |corrector| corrector.replace(node.loc.keyword, 'class...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/b_to_a_cop.rb
Ruby
mit
12,856
master
640
# frozen_string_literal: true module RuboCop module Cop module Test # This cop is only used to test infinite loop detection class BtoA < RuboCop::Cop::Base extend AutoCorrector def on_class(node) return unless node.loc.name.source.include?('B') add_offense(node.l...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/a_to_b_cop.rb
Ruby
mit
12,856
master
640
# frozen_string_literal: true module RuboCop module Cop module Test # This cop is only used to test infinite loop detection class AtoB < RuboCop::Cop::Base extend AutoCorrector def on_class(node) return unless node.loc.name.source.include?('A') add_offense(node.l...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/infinite_loop_during_autocorrect.rb
Ruby
mit
12,856
master
460
# frozen_string_literal: true module RuboCop module Cop module Test class InfiniteLoopDuringAutocorrectCop < RuboCop::Cop::Base extend AutoCorrector def on_class(node) add_offense(node, message: 'Class must be a Module') do |corrector| # Replace the offense with itsel...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/support/cops/same_name_in_multiple_namespace.rb
Ruby
mit
12,856
master
351
# frozen_string_literal: true module RuboCop module Cop module Test class SameNameInMultipleNamespace < RuboCop::Cop::Base; end module Foo class SameNameInMultipleNamespace < RuboCop::Cop::Base; end end module Bar class SameNameInMultipleNamespace < RuboCop::Cop::Base; e...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/tasks/changelog_spec.rb
Ruby
mit
12,856
master
5,709
# frozen_string_literal: true require_relative '../../tasks/changelog' RSpec.describe Changelog do subject(:changelog) do list = entries.to_h { |e| [e.path, e.content] } described_class.new(content: <<~CHANGELOG, entries: list) # Change log <!--- Do NOT edit this CHANGELOG.md file by ha...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/ruby_lsp/rubocop/addon_spec.rb
Ruby
mit
12,856
master
11,448
# frozen_string_literal: true # NOTE: These don't work in Ruby LSP. return if RUBY_VERSION < '3.0' || RUBY_ENGINE == 'jruby' || RuboCop::Platform.windows? require 'ruby_lsp/internal' require 'ruby_lsp/rubocop/addon' # NOTE: ruby-lsp enables LSP mode. Ideally the two requires should happen in isolation, but # for now ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/config_obsoletion_spec.rb
Ruby
mit
12,856
master
37,711
# frozen_string_literal: true RSpec.describe RuboCop::ConfigObsoletion do include FileHelper subject(:config_obsoletion) { described_class.new(configuration) } let(:configuration) { RuboCop::Config.new(hash, loaded_path) } let(:loaded_path) { 'example/.rubocop.yml' } let(:plugin_names) { [] } let(:plugin...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/path_util_spec.rb
Ruby
mit
12,856
master
5,251
# frozen_string_literal: true RSpec.describe RuboCop::PathUtil do describe '#relative_path' do it 'builds paths relative to PWD by default as a stop-gap' do relative = File.join(Dir.pwd, 'relative') expect(described_class.relative_path(relative)).to eq('relative') end it 'supports custom bas...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cops_documentation_generator_spec.rb
Ruby
mit
12,856
master
602
# frozen_string_literal: true require 'rubocop/cops_documentation_generator' RSpec.describe CopsDocumentationGenerator do around do |example| new_global = RuboCop::Cop::Registry.new([RuboCop::Cop::Style::HashSyntax]) RuboCop::Cop::Registry.with_temporary_global(new_global) { example.run } end it 'gener...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/magic_comment_spec.rb
Ruby
mit
12,856
master
10,278
# frozen_string_literal: true RSpec.describe RuboCop::MagicComment do shared_examples 'magic comment' do |comment, expectations = {}| encoding = expectations[:encoding] frozen_string = expectations[:frozen_string_literal] shareable_constant_value = expectations[:shareable_constant_value] typed = expe...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/result_cache_spec.rb
Ruby
mit
12,856
master
17,687
# frozen_string_literal: true RSpec.describe RuboCop::ResultCache, :isolated_environment do include EncodingHelper include FileHelper subject(:cache) { described_class.new(file, team, options, config_store, cache_root) } let(:registry) { RuboCop::Cop::Registry.global } let(:team) do RuboCop::Cop::Team....
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/plugin_spec.rb
Ruby
mit
12,856
master
1,135
# frozen_string_literal: true RSpec.describe RuboCop::Plugin do describe '.plugin_capable?' do subject { described_class.plugin_capable?(feature) } context 'when feature is a built-in plugin' do let(:feature) { 'rubocop/cop/internal_affairs' } it { is_expected.to be(true) } end context...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/remote_config_spec.rb
Ruby
mit
12,856
master
9,918
# frozen_string_literal: true RSpec.describe RuboCop::RemoteConfig do include FileHelper subject(:remote_config) { described_class.new(remote_config_url, base_dir).file } let(:remote_config_url) { 'http://example.com/rubocop.yml' } let(:base_dir) { '.' } let(:cached_file_name) { 'rubocop-e32e465e27910f2bc7...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/string_interpreter_spec.rb
Ruby
mit
12,856
master
1,123
# frozen_string_literal: true RSpec.describe RuboCop::StringInterpreter do describe '.interpret' do shared_examples 'simple escape' do |escaped| it "handles #{escaped}" do expect(described_class.interpret(escaped)).to eq escaped[1..] end end it 'handles hex' do expect(described...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cache_config_spec.rb
Ruby
mit
12,856
master
7,544
# frozen_string_literal: true RSpec.describe RuboCop::CacheConfig do include_context 'cli spec behavior' describe '.root_dir_from_toplevel_config' do context 'when no CacheRootDirectory is set', :isolated_environment do before do create_file('.rubocop.yml', <<~YAML) AllCops: ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/directive_comment_spec.rb
Ruby
mit
12,856
master
11,570
# frozen_string_literal: true RSpec.describe RuboCop::DirectiveComment do let(:directive_comment) { described_class.new(comment, cop_registry) } let(:comment) { instance_double(Parser::Source::Comment, text: text) } let(:cop_registry) do instance_double(RuboCop::Cop::Registry, names: all_cop_names, departmen...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/yaml_duplication_checker_spec.rb
Ruby
mit
12,856
master
1,907
# frozen_string_literal: true RSpec.describe RuboCop::YAMLDuplicationChecker do def check(yaml, &block) described_class.check(yaml, 'dummy.yaml', &block) end shared_examples 'call block' do it 'calls block' do called = false check(yaml) { called = true } expect(called).to be(true) ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/runner_formatter_invocation_spec.rb
Ruby
mit
12,856
master
4,855
# frozen_string_literal: true RSpec.describe RuboCop::Runner, :isolated_environment do describe 'how formatter is invoked' do subject(:runner) { described_class.new({}, RuboCop::ConfigStore.new) } include_context 'cli spec behavior' let(:formatter) { instance_double(RuboCop::Formatter::BaseFormatter).a...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/lockfile_spec.rb
Ruby
mit
12,856
master
2,747
# frozen_string_literal: true RSpec.describe RuboCop::Lockfile, :isolated_environment do include FileHelper subject { described_class.new } let(:lockfile) do create_file('Gemfile.lock', <<~LOCKFILE) GEM specs: rake (13.0.1) rspec (3.9.0) dep (1.0.0) d...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/pending_cops_reporter_spec.rb
Ruby
mit
12,856
master
1,903
# frozen_string_literal: true RSpec.describe RuboCop::PendingCopsReporter do include FileHelper describe 'when pending cops exist', :isolated_environment do subject(:report_pending_cops) { described_class.warn_if_needed(config) } let(:config) { RuboCop::Config.new(parent_config) } before do cr...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/target_finder_spec.rb
Ruby
mit
12,856
master
21,832
# frozen_string_literal: true RSpec.describe RuboCop::TargetFinder, :isolated_environment do include FileHelper ruby_extensions = %w[.rb .arb .axlsx .builder .gemfile .gemspec ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/version_spec.rb
Ruby
mit
12,856
master
5,447
# frozen_string_literal: true RSpec.describe RuboCop::Version do include FileHelper describe '.version' do subject { described_class.version(debug: debug) } context 'debug is false (default)' do let(:debug) { false } it { is_expected.to match(/\d+\.\d+\.\d+/) } it { is_expected.not_to ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/file_finder_spec.rb
Ruby
mit
12,856
master
2,118
# frozen_string_literal: true RSpec.describe RuboCop::FileFinder, :isolated_environment do include FileHelper subject(:finder) { Class.new.include(described_class).new } before do create_empty_file('file') create_empty_file(File.join('dir', 'file')) end describe '#find_file_upwards' do it 'ret...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/config_spec.rb
Ruby
mit
12,856
master
34,522
# frozen_string_literal: true RSpec.describe RuboCop::Config do include FileHelper subject(:configuration) { described_class.new(hash, loaded_path) } let(:hash) { {} } let(:loaded_path) { 'example/.rubocop.yml' } describe '.new' do context 'without arguments' do subject(:configuration) { describ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cli_spec.rb
Ruby
mit
12,856
master
85,910
# frozen_string_literal: true require 'timeout' RSpec.describe RuboCop::CLI, :isolated_environment do subject(:cli) { described_class.new } include_context 'cli spec behavior' context 'when interrupted' do it 'returns 130' do allow_any_instance_of(RuboCop::Runner).to receive(:aborting?).and_return(t...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/config_store_spec.rb
Ruby
mit
12,856
master
2,382
# frozen_string_literal: true RSpec.describe RuboCop::ConfigStore do subject(:config_store) { described_class.new } before do allow(RuboCop::ConfigLoader).to receive(:configuration_file_for) do |arg| # File tree: # file1 # dir/.rubocop.yml # dir/file2 # dir/subdir/file3 "#{...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/rake_task_spec.rb
Ruby
mit
12,856
master
5,918
# frozen_string_literal: true require 'rubocop/rake_task' require 'support/file_helper' RSpec.describe RuboCop::RakeTask do include FileHelper before { Rake::Task.clear } after { Rake::Task.clear } describe 'defining tasks' do # rubocop:todo Naming/InclusiveLanguage it 'creates a rubocop task and a...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/feature_loader_spec.rb
Ruby
mit
12,856
master
2,835
# frozen_string_literal: true RSpec.describe RuboCop::FeatureLoader do describe '.load' do subject(:load) do described_class.load(config_directory_path: config_directory_path, feature: feature) end let(:config_directory_path) do 'path-to-config' end let(:feature) do 'feature' ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/target_ruby_spec.rb
Ruby
mit
12,856
master
23,160
# frozen_string_literal: true RSpec.describe RuboCop::TargetRuby, :isolated_environment do include FileHelper subject(:target_ruby) { described_class.new(configuration) } let(:configuration) { RuboCop::Config.new(hash, loaded_path) } let(:default_version) { described_class::DEFAULT_VERSION } let(:hash) { ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/comment_config_spec.rb
Ruby
mit
12,856
master
25,819
# frozen_string_literal: true RSpec.describe RuboCop::CommentConfig do subject(:comment_config) { described_class.new(parse_source(source)) } describe '#cop_enabled_at_line?' do let(:source) do # rubocop:disable Lint/EmptyExpression, Lint/EmptyInterpolation <<~RUBY # rubocop:disable Metric...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/runner_spec.rb
Ruby
mit
12,856
master
19,338
# frozen_string_literal: true module RuboCop class Runner attr_writer :errors # Needed only for testing. end end RSpec.describe RuboCop::Runner, :isolated_environment do include FileHelper let(:formatter_output_path) { 'formatter_output.txt' } let(:formatter_output) { File.read(formatter_output_path) }...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/lsp_spec.rb
Ruby
mit
12,856
master
1,546
# frozen_string_literal: true RSpec.describe RuboCop::LSP, :lsp do describe '.enabled?' do context 'when `RuboCop::LSP.enable` is called' do before { described_class.enable } it 'returns true' do expect(described_class).to be_enabled end end context 'when `RuboCop::LSP.disable...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/config_loader_spec.rb
Ruby
mit
12,856
master
71,508
# frozen_string_literal: true RSpec.describe RuboCop::ConfigLoader do include FileHelper include_context 'cli spec behavior' before do described_class.debug = true # Force reload of default configuration described_class.default_configuration = nil RuboCop::ConfigFinder.project_root = nil end ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/config_regeneration_spec.rb
Ruby
mit
12,856
master
1,429
# frozen_string_literal: true RSpec.describe RuboCop::ConfigRegeneration, :isolated_environment do include FileHelper subject(:config_regeneration) { described_class.new } describe '#options' do subject { config_regeneration.options } context 'when no todo file exists' do it { is_expected.to eq(...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/options_spec.rb
Ruby
mit
12,856
master
32,842
# frozen_string_literal: true RSpec.describe RuboCop::Options, :isolated_environment do include FileHelper subject(:options) { described_class.new } include_context 'mock console output' def abs(path) File.expand_path(path) end describe 'option' do describe '-h/--help' do # HACK: `help` o...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/alignment_corrector_spec.rb
Ruby
mit
12,856
master
2,883
# frozen_string_literal: true RSpec.describe RuboCop::Cop::AlignmentCorrector, :config do let(:cop_class) { RuboCop::Cop::Test::AlignmentDirective } describe '#correct' do context 'simple indentation' do context 'with a positive column delta' do it 'indents' do expect_offense(<<~RUBY) ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/offense_spec.rb
Ruby
mit
12,856
master
6,827
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Offense do subject(:offense) do described_class.new(:convention, location, 'message', 'CopName', :corrected) end let(:location) do source_buffer = Parser::Source::Buffer.new('test', 1) source_buffer.source = "a\n" Parser::Source::Range.n...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/severity_spec.rb
Ruby
mit
12,856
master
2,818
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Severity do let(:info) { described_class.new(:info) } let(:refactor) { described_class.new(:refactor) } let(:convention) { described_class.new(:convention) } let(:warning) { described_class.new(:warning) } let(:error) { described_class.new(:error) } ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/team_spec.rb
Ruby
mit
12,856
master
13,619
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Team do subject(:team) { described_class.mobilize(cop_classes, config, options) } let(:cop_classes) { RuboCop::Cop::Registry.global } let(:config) { RuboCop::ConfigLoader.default_configuration } let(:options) { {} } let(:ruby_version) { RuboCop::Tar...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/util_spec.rb
Ruby
mit
12,856
master
2,740
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Util do before { stub_const('TestUtil', Class.new { include RuboCop::Cop::Util }) } describe '#line_range' do let(:source) do <<~RUBY foo = 1 bar = 2 class Test def some_method do_something ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/badge_spec.rb
Ruby
mit
12,856
master
3,515
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Badge do subject(:badge) { described_class.new(%w[Test ModuleMustBeAClassCop]) } it 'exposes department name' do expect(badge.department).to be(:Test) end it 'exposes cop name' do expect(badge.cop_name).to eql('ModuleMustBeAClassCop') end ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/commissioner_spec.rb
Ruby
mit
12,856
master
4,963
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Commissioner do describe '#investigate' do subject(:offenses) { report.offenses } let(:report) { commissioner.investigate(processed_source) } let(:cop_class) do stub_const('Fake::FakeCop', Class.new(RuboCop::Cop::Base) do ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/variable_force_spec.rb
Ruby
mit
12,856
master
1,350
# frozen_string_literal: true require 'rubocop/ast/sexp' RSpec.describe RuboCop::Cop::VariableForce do include RuboCop::AST::Sexp subject(:force) { described_class.new([]) } describe '#process_node' do before { force.variable_table.push_scope(s(:def)) } context 'when processing lvar node' do le...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/corrector_spec.rb
Ruby
mit
12,856
master
3,923
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Corrector do describe '#rewrite' do let(:source) do <<~RUBY.strip true and false RUBY end let(:processed_source) { parse_source(source) } let(:node) { processed_source.ast } let(:operator) { node.loc.operator } de...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/force_spec.rb
Ruby
mit
12,856
master
559
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Force do subject(:force) { described_class.new(cops) } let(:cops) { [instance_double(RuboCop::Cop::Base), instance_double(RuboCop::Cop::Base)] } describe '.force_name' do it 'returns the class name without namespace' do expect(RuboCop::Cop::V...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/generator_spec.rb
Ruby
mit
12,856
master
11,880
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Generator do subject(:generator) { described_class.new(cop_identifier, output: stdout) } let(:stdout) { StringIO.new } let(:cop_identifier) { 'Style/FakeCop' } before do allow(File).to receive(:write) stub_const('HOME_DIR', Dir.pwd) end ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/registry_spec.rb
Ruby
mit
12,856
master
11,500
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Registry do subject(:registry) { described_class.new(cops, options) } let(:cops) do [ RuboCop::Cop::Lint::BooleanSymbol, RuboCop::Cop::Lint::DuplicateMethods, RuboCop::Cop::Layout::FirstArrayElementIndentation, RuboCop::Cop::Me...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/annotation_comment_spec.rb
Ruby
mit
12,856
master
3,829
# frozen_string_literal: true RSpec.describe RuboCop::Cop::AnnotationComment do subject(:annotation) { described_class.new(comment, keywords) } let(:keywords) { ['TODO', 'FOR LATER', 'FIXME'] } let(:comment) { instance_double(Parser::Source::Comment, text: "# #{text}") } describe '#annotation?' do subjec...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/range_help_spec.rb
Ruby
mit
12,856
master
6,217
# frozen_string_literal: true RSpec.describe RuboCop::Cop::RangeHelp do before { stub_const('TestRangeHelp', klass) } let(:instance) do klass.new(processed_source: processed_source) end let(:klass) do Class.new do include RuboCop::Cop::RangeHelp def initialize(processed_source:) ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/visibility_help_spec.rb
Ruby
mit
12,856
master
2,089
# frozen_string_literal: true RSpec.describe RuboCop::Cop::VisibilityHelp do describe '#node_visibility' do subject do instance.__send__(:node_visibility, node) end let(:instance) do klass.new end let(:klass) do mod = described_class Class.new do include mod ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/message_annotator_spec.rb
Ruby
mit
12,856
master
8,281
# frozen_string_literal: true RSpec.describe RuboCop::Cop::MessageAnnotator do let(:options) { {} } let(:config) { RuboCop::Config.new({}) } let(:cop_name) { 'Cop/Cop' } let(:annotator) { described_class.new(config, cop_name, config[cop_name], options) } describe '#annotate' do subject(:annotate) { anno...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/cop_spec.rb
Ruby
mit
12,856
master
16,987
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Cop, :config do include FileHelper let(:source) { 'code = {some: :ruby}' } let(:location) { source_range(0...1) } before { cop.send(:begin_investigation, processed_source) } it 'initially has 0 offenses' do expect(cop.offenses).to be_empty e...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/access_modifier_indentation_spec.rb
Ruby
mit
12,856
master
13,405
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::AccessModifierIndentation, :config do let(:config) do c = cop_config.merge('SupportedStyles' => %w[indent outdent]) RuboCop::Config .new('Layout/AccessModifierIndentation' => c, 'Layout/IndentationWidth' => { 'Width' => inden...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/indentation_style_spec.rb
Ruby
mit
12,856
master
5,829
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::IndentationStyle, :config do let(:config) do supported_styles = { 'SupportedStyles' => %w[spaces tabs] } RuboCop::Config.new( 'Layout/IndentationWidth' => { 'Width' => 2 }, 'Layout/IndentationStyle' => cop_config.merge(supported_s...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/space_after_not_spec.rb
Ruby
mit
12,856
master
1,319
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceAfterNot, :config do it 'registers an offense and corrects a single space after !' do expect_offense(<<~RUBY) ! something ^^^^^^^^^^^ Do not leave space between `!` and its argument. RUBY expect_correction(<<~RUBY) ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/space_before_semicolon_spec.rb
Ruby
mit
12,856
master
2,302
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceBeforeSemicolon, :config do let(:config) { RuboCop::Config.new('Layout/SpaceInsideBlockBraces' => brace_config) } let(:brace_config) { {} } it 'registers an offense and corrects space before semicolon' do expect_offense(<<~RUBY) x...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/block_end_newline_spec.rb
Ruby
mit
12,856
master
6,716
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::BlockEndNewline, :config do it 'accepts a one-liner' do expect_no_offenses('test do foo end') end it 'accepts multiline blocks with newlines before the end' do expect_no_offenses(<<~RUBY) test do foo end RUBY en...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/comment_indentation_spec.rb
Ruby
mit
12,856
master
12,932
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::CommentIndentation, :config do let(:config) do RuboCop::Config .new('Layout/IndentationWidth' => { 'Width' => indentation_width }, 'Layout/CommentIndentation' => { 'AllowForAlignment' => allow_for_alignment }) end let(:indent...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/space_inside_parens_spec.rb
Ruby
mit
12,856
master
7,922
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInsideParens, :config do context 'when EnforcedStyle is no_space' do let(:cop_config) { { 'EnforcedStyle' => 'no_space' } } it 'registers an offense for spaces inside parens' do expect_offense(<<~RUBY) f( 3) ^ Sp...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/case_indentation_spec.rb
Ruby
mit
12,856
master
25,415
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::CaseIndentation, :config do let(:config) do merged = RuboCop::ConfigLoader.default_configuration['Layout/CaseIndentation'].merge(cop_config) RuboCop::Config.new('Layout/CaseIndentation' => merged, 'Layout/IndentationWi...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/space_around_method_call_operator_spec.rb
Ruby
mit
12,856
master
12,021
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceAroundMethodCallOperator, :config do shared_examples 'offense' do |name, offense, correction| it "registers an offense and corrects when #{name}" do expect_offense(offense) expect_correction(correction) end end context ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/parameter_alignment_spec.rb
Ruby
mit
12,856
master
6,026
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::ParameterAlignment, :config do let(:config) do RuboCop::Config.new('Layout/ParameterAlignment' => cop_config, 'Layout/IndentationWidth' => { 'Width' => indentation_width })...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/space_before_brackets_spec.rb
Ruby
mit
12,856
master
6,638
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceBeforeBrackets, :config do context 'when referencing' do it 'registers an offense and corrects when using space between lvar receiver and left brackets' do expect_offense(<<~RUBY) collection = do_something collection [i...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/space_inside_reference_brackets_spec.rb
Ruby
mit
12,856
master
13,486
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInsideReferenceBrackets, :config do context 'with space inside empty brackets not allowed' do let(:cop_config) { { 'EnforcedStyleForEmptyBrackets' => 'no_space' } } it 'accepts empty brackets with no space inside' do expect_no_off...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/else_alignment_spec.rb
Ruby
mit
12,856
master
19,563
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::ElseAlignment, :config do let(:config) { RuboCop::Config.new('Layout/EndAlignment' => end_alignment_config) } let(:end_alignment_config) { { 'Enabled' => true, 'EnforcedStyleAlignWith' => 'variable' } } it 'accepts a ternary if' do expect_no...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/def_end_alignment_spec.rb
Ruby
mit
12,856
master
3,425
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::DefEndAlignment, :config do context 'when EnforcedStyleAlignWith is start_of_line' do let(:cop_config) { { 'EnforcedStyleAlignWith' => 'start_of_line', 'AutoCorrect' => true } } it_behaves_like 'misaligned', <<~RUBY, false def test ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/first_hash_element_indentation_spec.rb
Ruby
mit
12,856
master
24,120
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::FirstHashElementIndentation, :config do let(:config) do supported_styles = { 'SupportedStyles' => %w[special_inside_parentheses consistent align_braces] } RuboCop::Config.new('Layout/HashAlignment' => a...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/heredoc_indentation_spec.rb
Ruby
mit
12,856
master
10,262
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::HeredocIndentation, :config do let(:allow_heredoc) { true } let(:other_cops) { { 'Layout/LineLength' => { 'Max' => 5, 'AllowHeredoc' => allow_heredoc } } } shared_examples 'all heredoc type' do |quote| context "quoted by #{quote}" do i...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/argument_alignment_spec.rb
Ruby
mit
12,856
master
20,819
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::ArgumentAlignment, :config do let(:config) do RuboCop::Config.new('Layout/ArgumentAlignment' => cop_config, 'Layout/IndentationWidth' => { 'Width' => indentation_width }) ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/empty_lines_around_access_modifier_spec.rb
Ruby
mit
12,856
master
17,033
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EmptyLinesAroundAccessModifier, :config do context 'EnforcedStyle is `around`' do let(:cop_config) { { 'EnforcedStyle' => 'around' } } %w[private protected public module_function].each do |access_modifier| it "requires blank line befor...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/condition_position_spec.rb
Ruby
mit
12,856
master
1,291
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::ConditionPosition, :config do %w[if unless while until].each do |keyword| it 'registers an offense and corrects for condition on the next line' do expect_offense(<<~RUBY) #{keyword} x == 10 ^^^^^^^ Place the conditio...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/space_inside_block_braces_spec.rb
Ruby
mit
12,856
master
11,223
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInsideBlockBraces, :config do let(:supported_styles) { %w[space no_space] } let(:cop_config) do { 'EnforcedStyle' => 'space', 'SupportedStyles' => supported_styles, 'SpaceBeforeBlockParameters' => true } end cont...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/empty_lines_after_module_inclusion_spec.rb
Ruby
mit
12,856
master
7,372
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EmptyLinesAfterModuleInclusion, :config do described_class::MODULE_INCLUSION_METHODS.each do |method| it "registers an offense and corrects for code that immediately follows #{method}" do expect_offense(<<~RUBY, method: method) #{me...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/space_after_method_name_spec.rb
Ruby
mit
12,856
master
1,835
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceAfterMethodName, :config do it 'registers an offense and corrects def with space before the parenthesis' do expect_offense(<<~RUBY) def func (x) ^ Do not put a space between a method name and the opening parenthesis. ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/multiline_method_parameter_line_breaks_spec.rb
Ruby
mit
12,856
master
6,525
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::MultilineMethodParameterLineBreaks, :config do context 'when one parameter on same line' do it 'does not add any offenses' do expect_no_offenses(<<~RUBY) def taz(abc) end RUBY end end context 'when there are n...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/multiline_method_argument_line_breaks_spec.rb
Ruby
mit
12,856
master
7,139
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::MultilineMethodArgumentLineBreaks, :config do context 'with one argument on same line as the method call' do it 'does not add any offenses' do expect_no_offenses(<<~RUBY) taz("abc") RUBY end end context 'when bracket ...
github
rubocop/rubocop
https://github.com/rubocop/rubocop
spec/rubocop/cop/layout/space_inside_hash_literal_braces_spec.rb
Ruby
mit
12,856
master
10,790
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInsideHashLiteralBraces, :config do let(:cop_config) { { 'EnforcedStyle' => 'space' } } context 'with space inside empty braces not allowed' do let(:cop_config) { { 'EnforcedStyleForEmptyBraces' => 'no_space' } } it 'accepts empty br...