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/rubocop/cop/style/redundant_sort_spec.rb | Ruby | mit | 12,856 | master | 14,390 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantSort, :config do
it 'registers an offense when first is called with sort' do
expect_offense(<<~RUBY)
[1, 2, 3].sort.first
^^^^^^^^^^ Use `min` instead of `sort...first`.
RUBY
expect_correction(<<~RUBY)
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/redundant_constant_base_spec.rb | Ruby | mit | 12,856 | master | 2,404 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantConstantBase, :config do
let(:other_cops) { { 'Lint/ConstantResolution' => { 'Enabled' => false } } }
context 'with prefixed constant in class' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class Foo
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/nested_modifier_spec.rb | Ruby | mit | 12,856 | master | 3,130 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::NestedModifier, :config do
shared_examples 'not correctable' do |keyword|
it "does not autocorrect when #{keyword} is the outer modifier" do
expect_offense(<<~RUBY, keyword: keyword)
something if a %{keyword} b
^^ A... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/percent_literal_delimiters_spec.rb | Ruby | mit | 12,856 | master | 12,783 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::PercentLiteralDelimiters, :config do
let(:cop_config) { { 'PreferredDelimiters' => { 'default' => '[]' } } }
context '`default` override' do
let(:cop_config) { { 'PreferredDelimiters' => { 'default' => '[]', '%' => '()' } } }
it 'allows al... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/exact_regexp_match_spec.rb | Ruby | mit | 12,856 | master | 3,347 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ExactRegexpMatch, :config do
it 'registers an offense when using `string =~ /\Astring\z/`' do
expect_offense(<<~'RUBY')
string =~ /\Astring\z/
^^^^^^^^^^^^^^^^^^^^^^ Use `string == 'string'`.
RUBY
expect_correction(<<~RUBY)
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/if_unless_modifier_of_if_unless_spec.rb | Ruby | mit | 12,856 | master | 2,843 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::IfUnlessModifierOfIfUnless, :config do
it 'provides a good error message' do
expect_offense(<<~RUBY)
condition ? then_part : else_part unless external_condition
^^^^^^ Avoid modifier `unless` after ano... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/variable_interpolation_spec.rb | Ruby | mit | 12,856 | master | 2,767 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::VariableInterpolation, :config do
it 'registers an offense for interpolated global variables in string' do
expect_offense(<<~'RUBY')
puts "this is a #$test"
^^^^^ Replace interpolated variable `$test` with expression `... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/bitwise_predicate_spec.rb | Ruby | mit | 12,856 | master | 5,461 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::BitwisePredicate, :config do
context 'when checking any set bits' do
context 'when Ruby >= 2.5', :ruby25 do
it 'registers an offense when using `&` in conjunction with `predicate` for comparisons' do
expect_offense(<<~RUBY)
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/perl_backrefs_spec.rb | Ruby | mit | 12,856 | master | 3,675 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::PerlBackrefs, :config do
it 'autocorrects puts $1 to puts Regexp.last_match(1)' do
expect_offense(<<~RUBY)
puts $1
^^ Prefer `Regexp.last_match(1)` over `$1`.
RUBY
expect_correction(<<~RUBY)
puts Regexp.last_match(1... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/for_spec.rb | Ruby | mit | 12,856 | master | 13,305 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::For, :config do
context 'when each is the enforced style' do
let(:cop_config) { { 'EnforcedStyle' => 'each' } }
it 'registers an offense for for' do
expect_offense(<<~RUBY)
def func
for n in [1, 2, 3] do
^^^^... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/negated_unless_spec.rb | Ruby | mit | 12,856 | master | 4,344 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::NegatedUnless do
subject(:cop) do
config = RuboCop::Config.new(
'Style/NegatedUnless' => {
'SupportedStyles' => %w[both prefix postfix],
'EnforcedStyle' => 'both'
}
)
described_class.new(config)
end
describ... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/unless_logical_operators_spec.rb | Ruby | mit | 12,856 | master | 5,758 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::UnlessLogicalOperators, :config do
context 'EnforcedStyle is `forbid_mixed_logical_operators`' do
let(:cop_config) { { 'EnforcedStyle' => 'forbid_mixed_logical_operators' } }
it 'registers an offense when using `&&` and `||`' do
expect_... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/raise_args_spec.rb | Ruby | mit | 12,856 | master | 10,565 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RaiseArgs, :config do
context 'when enforced style is compact' do
let(:cop_config) { { 'EnforcedStyle' => 'compact' } }
context 'with a raise with 2 args' do
it 'reports an offense' do
expect_offense(<<~RUBY)
raise Run... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/comparable_clamp_spec.rb | Ruby | mit | 12,856 | master | 7,075 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ComparableClamp, :config do
context 'target ruby version >= 2.4', :ruby24 do
it 'registers and corrects an offense when using `if x < low` / `elsif high < x` / `else`' do
expect_offense(<<~RUBY)
if x < low
^^^^^^^^^^ Use `x.c... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/negated_while_spec.rb | Ruby | mit | 12,856 | master | 3,463 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::NegatedWhile, :config do
it 'registers an offense for while with exclamation point condition' do
expect_offense(<<~RUBY)
while !a_condition
^^^^^^^^^^^^^^^^^^ Favor `until` over `while` for negative conditions.
some_method
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/collection_methods_spec.rb | Ruby | mit | 12,856 | master | 7,120 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::CollectionMethods, :config do
cop_config = {
'PreferredMethods' => {
'collect' => 'map',
'inject' => 'reduce',
'detect' => 'find',
'find_all' => 'select',
'member?' => 'include?'
}
}
let(:cop_config) { cop_co... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/ambiguous_endless_method_definition_spec.rb | Ruby | mit | 12,856 | master | 2,043 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::AmbiguousEndlessMethodDefinition, :config do
context 'Ruby >= 3.0', :ruby30 do
it 'does not register an offense for a non endless method' do
expect_no_offenses(<<~RUBY)
def foo
end
RUBY
end
%i[and or if unless ... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/trailing_comma_in_array_literal_spec.rb | Ruby | mit | 12,856 | master | 10,760 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::TrailingCommaInArrayLiteral, :config do
shared_examples 'single line lists' do |extra_info|
it 'registers an offense for trailing comma' do
expect_offense(<<~RUBY)
VALUES = [1001, 2020, 3333, ]
^ Avo... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/nil_lambda_spec.rb | Ruby | mit | 12,856 | master | 8,409 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::NilLambda, :config do
context 'block lambda' do
it 'registers an offense when returning nil implicitly' do
expect_offense(<<~RUBY)
lambda do
^^^^^^^^^ Use an empty lambda instead of always returning nil.
nil
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/redundant_begin_spec.rb | Ruby | mit | 12,856 | master | 21,311 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RedundantBegin, :config do
it 'reports an offense for single line def with redundant begin block' do
expect_offense(<<~RUBY)
def func; begin; x; y; rescue; z end; end
^^^^^ Redundant `begin` block detected.
RUBY
expe... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/rescue_modifier_spec.rb | Ruby | mit | 12,856 | master | 7,108 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::RescueModifier, :config do
let(:config) { RuboCop::Config.new('Layout/IndentationWidth' => { 'Width' => 2 }) }
it 'registers an offense for modifier rescue' do
expect_offense(<<~RUBY)
method rescue handle
^^^^^^^^^^^^^^^^^^^^ Avoid ... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/comparable_between_spec.rb | Ruby | mit | 12,856 | master | 2,215 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ComparableBetween, :config do
[
'x >= min && x <= max',
'x >= min && max >= x',
'min <= x && x <= max',
'min <= x && max >= x',
'x <= max && x >= min',
'x <= max && min <= x',
'max >= x && x >= min',
'max >= x && min <=... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/super_with_args_parentheses_spec.rb | Ruby | mit | 12,856 | master | 810 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::SuperWithArgsParentheses, :config do
it 'registers an offense when using `super` without parenthesized arguments' do
expect_offense(<<~RUBY)
super name, age
^^^^^^^^^^^^^^^ Use parentheses for `super` with arguments.
RUBY
expe... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/double_negation_spec.rb | Ruby | mit | 12,856 | master | 22,857 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::DoubleNegation, :config do
let(:cop_config) { { 'EnforcedStyle' => enforced_style } }
shared_examples 'common' do
it 'registers an offense and corrects for `!!` when not a return location' do
expect_offense(<<~RUBY)
def foo?
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/single_line_do_end_block_spec.rb | Ruby | mit | 12,856 | master | 4,634 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::SingleLineDoEndBlock, :config do
it 'registers an offense when using single line `do`...`end`' do
expect_offense(<<~RUBY)
foo do bar end
^^^^^^^^^^^^^^ Prefer multiline `do`...`end` block.
RUBY
expect_correction(<<~RUBY)
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/constant_visibility_spec.rb | Ruby | mit | 12,856 | master | 4,641 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::ConstantVisibility, :config do
context 'when defining a constant in a class' do
context 'with a single-statement body' do
it 'registers an offense when not using a visibility declaration' do
expect_offense(<<~RUBY)
class Fo... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/symbol_literal_spec.rb | Ruby | mit | 12,856 | master | 853 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::SymbolLiteral, :config do
it 'registers an offense for word-line symbols using string syntax' do
expect_offense(<<~RUBY)
x = { :"test" => 0, :"other" => 1 }
^^^^^^^^ Do not use strings for word-like symbol literals.... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/ternary_parentheses_spec.rb | Ruby | mit | 12,856 | master | 31,228 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::TernaryParentheses, :config do
shared_examples 'safe assignment disabled' do |style, message|
let(:cop_config) { { 'EnforcedStyle' => style, 'AllowSafeAssignment' => false } }
it 'registers an offense for parens around assignment' do
ex... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/hash_as_last_array_item_spec.rb | Ruby | mit | 12,856 | master | 5,014 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::HashAsLastArrayItem, :config do
context 'when EnforcedStyle is braces' do
let(:cop_config) { { 'EnforcedStyle' => 'braces' } }
it 'registers an offense and corrects when hash without braces' do
expect_offense(<<~RUBY)
[1, 2, one... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/style/lambda_spec.rb | Ruby | mit | 12,856 | master | 15,241 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::Lambda, :config do
context 'with enforced `lambda` style' do
let(:cop_config) { { 'EnforcedStyle' => 'lambda' } }
context 'with a single line lambda literal' do
context 'with arguments' do
it 'registers an offense' do
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cop/migration/department_name_spec.rb | Ruby | mit | 12,856 | master | 4,204 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::Migration::DepartmentName, :config do
context 'when todo/enable comments have cop names without departments' do
let(:tip) { 'Run `rubocop -a --only Migration/DepartmentName` to fix.' }
let(:warning) do
<<~OUTPUT
file.rb: Warning: no dep... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/mcp/server_spec.rb | Ruby | mit | 12,856 | master | 13,951 | # frozen_string_literal: true
RSpec.describe RuboCop::MCP::Server, :isolated_environment, :lsp do
include MCPHelper
subject(:result) { run_server_on_requests(*requests) }
let(:messages) { result[0] }
let(:response) { messages.first }
let(:parsed_result) do
JSON.parse(response[:result][:content].first[:... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/lsp/diagnostic_spec.rb | Ruby | mit | 12,856 | master | 1,508 | # frozen_string_literal: true
require 'rubocop/lsp/diagnostic'
RSpec.describe RuboCop::LSP::Diagnostic do
include CopHelper
subject(:diagnostic) do
described_class.new(nil, offense, 'file:///path/to/file.rb', nil, processed_source)
end
let(:source) do
<<~RUBY
# frozen_string_literal: true
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/lsp/server_spec.rb | Ruby | mit | 12,856 | master | 43,477 | # frozen_string_literal: true
RSpec.describe RuboCop::LSP::Server, :isolated_environment do
include LSPHelper
subject(:result) { run_server_on_requests(*requests) }
after do
RuboCop::LSP.disable
end
let(:messages) { result[0] }
let(:stderr) { result[1].string }
let(:eol) do
if RuboCop::Platfo... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/lsp/severity_spec.rb | Ruby | mit | 12,856 | master | 1,377 | # frozen_string_literal: true
RSpec.describe RuboCop::LSP::Severity do
describe '.find_by' do
subject(:lsp_severity) { described_class.find_by(rubocop_severity) }
context 'when RuboCop severity is fatal' do
let(:rubocop_severity) { 'fatal' }
it { is_expected.to eq(LanguageServer::Protocol::Cons... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/emacs_style_formatter_spec.rb | Ruby | mit | 12,856 | master | 3,146 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::EmacsStyleFormatter, :config do
subject(:formatter) { described_class.new(output) }
let(:cop_class) { RuboCop::Cop::Base }
let(:source) { %w[a b cdefghi].join("\n") }
let(:output) { StringIO.new }
before { cop.send(:begin_investigation, proce... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/clang_style_formatter_spec.rb | Ruby | mit | 12,856 | master | 4,382 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::ClangStyleFormatter, :config do
subject(:formatter) { described_class.new(output) }
let(:cop_class) { RuboCop::Cop::Base }
let(:output) { StringIO.new }
before { cop.send(:begin_investigation, processed_source) }
describe '#report_file' do
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/tap_formatter_spec.rb | Ruby | mit | 12,856 | master | 5,353 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::TapFormatter do
subject(:formatter) { described_class.new(output) }
let(:output) { StringIO.new }
let(:files) do
%w[lib/rubocop.rb spec/spec_helper.rb exe/rubocop].map do |path|
File.expand_path(path)
end
end
describe '#file_fi... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/json_formatter_spec.rb | Ruby | mit | 12,856 | master | 5,122 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::JSONFormatter do
subject(:formatter) { described_class.new(output) }
let(:output) { StringIO.new }
let(:files) { %w[/path/to/file1 /path/to/file2] }
let(:location) do
source_buffer = Parser::Source::Buffer.new('test', 1)
source_buffer.so... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/auto_gen_config_formatter_spec.rb | Ruby | mit | 12,856 | master | 3,309 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::AutoGenConfigFormatter do
subject(:formatter) { described_class.new(output) }
let(:output) { StringIO.new }
let(:files) do
%w[lib/rubocop.rb spec/spec_helper.rb exe/rubocop].map do |path|
File.expand_path(path)
end
end
describe... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/fuubar_style_formatter_spec.rb | Ruby | mit | 12,856 | master | 3,235 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::FuubarStyleFormatter do
subject(:formatter) { described_class.new(output) }
let(:output) { StringIO.new }
let(:files) { %w[lib/rubocop.rb spec/spec_helper.rb].map { |path| File.expand_path(path) } }
describe '#with_color' do
around do |exa... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/html_formatter_spec.rb | Ruby | mit | 12,856 | master | 1,999 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::HTMLFormatter, :isolated_environment do
spec_root = File.expand_path('../..', __dir__)
around do |example|
project_path = File.join(spec_root, 'fixtures/html_formatter/project')
FileUtils.cp_r(project_path, '.')
Dir.chdir(File.basename(... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/text_util_spec.rb | Ruby | mit | 12,856 | master | 1,243 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::TextUtil do
describe 'pluralize' do
it 'does not change 0 to no' do
pluralized_text = described_class.pluralize(0, 'file')
expect(pluralized_text).to eq('0 files')
end
it 'changes 0 to no when configured' do
pluralized_t... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/colorizable_spec.rb | Ruby | mit | 12,856 | master | 2,361 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::Colorizable do
let(:formatter_class) do
Class.new(RuboCop::Formatter::BaseFormatter) do
include RuboCop::Formatter::Colorizable
end
end
let(:options) { {} }
let(:formatter) { formatter_class.new(output, options) }
let(:output) ... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/file_list_formatter_spec.rb | Ruby | mit | 12,856 | master | 780 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::FileListFormatter, :config do
subject(:formatter) { described_class.new(output) }
let(:output) { StringIO.new }
let(:cop_class) { RuboCop::Cop::Base }
let(:source) { %w[a b cdefghi].join("\n") }
before { cop.send(:begin_investigation, process... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/quiet_formatter_spec.rb | Ruby | mit | 12,856 | master | 4,612 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::QuietFormatter do
subject(:formatter) { described_class.new(output) }
before { Rainbow.enabled = true }
after { Rainbow.enabled = false }
let(:output) { StringIO.new }
describe '#report_file' do
before { formatter.report_file(file, [off... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/markdown_formatter_spec.rb | Ruby | mit | 12,856 | master | 1,671 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::MarkdownFormatter, :isolated_environment do
spec_root = File.expand_path('../..', __dir__)
around do |example|
project_path = File.join(spec_root, 'fixtures/markdown_formatter/project')
FileUtils.cp_r(project_path, '.')
Dir.chdir(File.b... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/worst_offenders_formatter_spec.rb | Ruby | mit | 12,856 | master | 950 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::WorstOffendersFormatter do
subject(:formatter) { described_class.new(output) }
let(:output) { StringIO.new }
let(:files) do
%w[lib/rubocop.rb spec/spec_helper.rb exe/rubocop].map do |path|
File.expand_path(path)
end
end
describ... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/junit_formatter_spec.rb | Ruby | mit | 12,856 | master | 2,216 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::JUnitFormatter, :config do
subject(:formatter) { described_class.new(output) }
let(:output) { StringIO.new }
let(:cop_class) { RuboCop::Cop::Layout::SpaceInsideBlockBraces }
let(:source) { %w[foo bar baz].join("\n") }
before { cop.send(:begin... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/pacman_formatter_spec.rb | Ruby | mit | 12,856 | master | 3,499 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::PacmanFormatter do
subject(:formatter) { described_class.new(output) }
let(:output) { StringIO.new }
describe '#next_step' do
subject(:next_step) { formatter.next_step(offenses) }
context 'when no offenses are detected' do
let(:off... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/offense_count_formatter_spec.rb | Ruby | mit | 12,856 | master | 3,947 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::OffenseCountFormatter do
subject(:formatter) { described_class.new(output, options) }
let(:output) { StringIO.new }
let(:options) { { display_style_guide: false } }
let(:files) do
%w[lib/rubocop.rb spec/spec_helper.rb exe/rubocop].map do |p... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/progress_formatter_spec.rb | Ruby | mit | 12,856 | master | 4,853 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::ProgressFormatter do
subject(:formatter) { described_class.new(output) }
let(:output) { StringIO.new }
let(:files) do
%w[lib/rubocop.rb spec/spec_helper.rb exe/rubocop].map do |path|
File.expand_path(path)
end
end
describe '#fi... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/disabled_config_formatter_spec.rb | Ruby | mit | 12,856 | master | 7,883 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::DisabledConfigFormatter, :isolated_environment,
:restore_registry do
include FileHelper
subject(:formatter) { described_class.new(output) }
include_context 'mock console output'
let(:output) do
io = StringIO.new
def io.... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/formatter_set_spec.rb | Ruby | mit | 12,856 | master | 4,851 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::FormatterSet do
subject(:formatter_set) { described_class.new }
win_close = lambda do |fset|
fset.close_output_files
fset.each { |f| f.instance_variable_set :@output, nil }
end
it 'responds to all formatter API methods' do
%i[starte... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/simple_text_formatter_spec.rb | Ruby | mit | 12,856 | master | 5,390 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::SimpleTextFormatter do
subject(:formatter) { described_class.new(output) }
before { Rainbow.enabled = true }
after { Rainbow.enabled = false }
let(:output) { StringIO.new }
shared_examples 'report for severity' do |severity|
let(:offens... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/formatter/github_actions_formatter_spec.rb | Ruby | mit | 12,856 | master | 2,466 | # frozen_string_literal: true
RSpec.describe RuboCop::Formatter::GitHubActionsFormatter, :config do
subject(:formatter) { described_class.new(output, formatter_options) }
let(:formatter_options) { {} }
let(:cop_class) { RuboCop::Cop::Base }
let(:output) { StringIO.new }
describe '#finished' do
let(:fil... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/server/cli_spec.rb | Ruby | mit | 12,856 | master | 9,002 | # frozen_string_literal: true
RSpec.describe RuboCop::Server::CLI, :isolated_environment do
subject(:cli) { described_class.new }
include_context 'cli spec behavior'
if RuboCop::Server.support_server?
before do
allow_any_instance_of(RuboCop::Server::Core).to receive(:server_mode?).and_return(false) #... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/server/cache_spec.rb | Ruby | mit | 12,856 | master | 6,483 | # frozen_string_literal: true
RSpec.describe RuboCop::Server::Cache do
subject(:cache_class) { described_class }
include_context 'cli spec behavior'
describe '.cache_path' do
context 'when cache root path is not specified as default' do
before do
cache_class.cache_root_path = nil
allo... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/server/rubocop_server_spec.rb | Ruby | mit | 12,856 | master | 8,969 | # frozen_string_literal: true
require 'open3'
RSpec.describe 'rubocop --server', :isolated_environment do # rubocop:disable RSpec/DescribeClass
let(:rubocop) { "#{RuboCop::ConfigLoader::RUBOCOP_HOME}/exe/rubocop" }
include_context 'cli spec behavior'
before do
# Makes sure the project dir of rubocop serve... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/server/client_command/exec_spec.rb | Ruby | mit | 12,856 | master | 1,344 | # frozen_string_literal: true
RSpec.describe RuboCop::Server::ClientCommand::Exec do
if RuboCop::Server.support_server?
it 'does not read from $stdin when -s/--stdin not specified' do
exec_command = described_class.new
expect(ARGV).to receive(:include?).with('-s').and_return(false)
expect(ARGV... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/config_obsoletion/renamed_cop_spec.rb | Ruby | mit | 12,856 | master | 1,012 | # frozen_string_literal: true
RSpec.describe RuboCop::ConfigObsoletion::RenamedCop do
subject(:rule) { described_class.new(config, old_name, new_name) }
let(:config) { instance_double(RuboCop::Config, loaded_path: '.rubocop.yml').as_null_object }
let(:old_name) { 'Style/MyCop' }
describe '#message' do
su... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cli/options_spec.rb | Ruby | mit | 12,856 | master | 90,613 | # frozen_string_literal: true
require 'open3'
RSpec.describe 'RuboCop::CLI options', :isolated_environment do # rubocop:disable RSpec/DescribeClass
subject(:cli) { RuboCop::CLI.new }
include_context 'cli spec behavior'
let(:rubocop) { "#{RuboCop::ConfigLoader::RUBOCOP_HOME}/exe/rubocop" }
before do
Rub... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cli/autocorrect_spec.rb | Ruby | mit | 12,856 | master | 123,505 | # frozen_string_literal: true
RSpec.describe 'RuboCop::CLI --autocorrect', :isolated_environment do # rubocop:disable RSpec/DescribeClass
subject(:cli) { RuboCop::CLI.new }
include_context 'cli spec behavior'
before do
RuboCop::ConfigLoader.default_configuration = nil
RuboCop::ConfigLoader.default_conf... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cli/suggest_extensions_spec.rb | Ruby | mit | 12,856 | master | 12,318 | # frozen_string_literal: true
require 'timeout'
RSpec.describe 'RuboCop::CLI SuggestExtensions', :isolated_environment do # rubocop:disable RSpec/DescribeClass
subject(:cli) { RuboCop::CLI.new }
include_context 'cli spec behavior'
describe 'extension suggestions', :config do
matcher :suggest_extensions do... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cli/disable_uncorrectable_spec.rb | Ruby | mit | 12,856 | master | 26,648 | # frozen_string_literal: true
RSpec.describe 'RuboCop::CLI --disable-uncorrectable', :isolated_environment do # rubocop:disable RSpec/DescribeClass
subject(:cli) { RuboCop::CLI.new }
include_context 'cli spec behavior'
describe '--disable-uncorrectable' do
let(:cli_opts) { %w[--autocorrect-all --format sim... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/cli/auto_gen_config_spec.rb | Ruby | mit | 12,856 | master | 68,257 | # frozen_string_literal: true
RSpec.describe 'RuboCop::CLI --auto-gen-config', :isolated_environment do # rubocop:disable RSpec/DescribeClass
subject(:cli) { RuboCop::CLI.new }
include_context 'cli spec behavior'
describe '--auto-gen-config' do
before do
RuboCop::Formatter::DisabledConfigFormatter.co... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/plugin/loader_spec.rb | Ruby | mit | 12,856 | master | 930 | # frozen_string_literal: true
RSpec.describe RuboCop::Plugin::Loader do
describe '.load' do
subject(:plugins) { described_class.load(plugin_configs) }
context 'when plugin config is a string' do
let(:plugin_configs) { ['rubocop/cop/internal_affairs'] }
let(:plugin) { plugins.first }
it 'r... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/plugin/configuration_integrator_spec.rb | Ruby | mit | 12,856 | master | 3,683 | # frozen_string_literal: true
require 'lint_roller'
RSpec.describe RuboCop::Plugin::ConfigurationIntegrator, :isolated_environment do
include FileHelper
describe '.integrate_plugins_into_rubocop_config' do
subject(:integrated_config) do
described_class.integrate_plugins_into_rubocop_config(rubocop_conf... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/ext/regexp_node_spec.rb | Ruby | mit | 12,856 | master | 3,081 | # frozen_string_literal: true
require 'timeout'
RSpec.describe RuboCop::Ext::RegexpNode do
let(:source) { '/(hello)(?<foo>world)(?:not captured)/' }
let(:processed_source) { parse_source(source) }
let(:ast) { processed_source.ast }
let(:node) { ast }
describe '#each_capture' do
subject(:captures) { nod... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/rubocop/rspec/expect_offense_spec.rb | Ruby | mit | 12,856 | master | 987 | # frozen_string_literal: true
RSpec.describe RuboCop::RSpec::ExpectOffense, :config do
context 'with a cop that loops during autocorrection' do
let(:cop_class) { RuboCop::Cop::Test::InfiniteLoopDuringAutocorrectCop }
it '`expect_no_corrections` raises' do
expect_offense(<<~RUBY)
class Test
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | spec/core_ext/string.rb | Ruby | mit | 12,856 | master | 580 | # frozen_string_literal: true
class String
unless method_defined? :strip_margin
# The method strips the characters preceding a special margin character.
# Useful for HEREDOCs and other multi-line strings.
#
# @example
#
# code = <<-END.strip_margin('|')
# |def test
# | some... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/cops_documentation.rake | Ruby | mit | 12,856 | master | 513 | # frozen_string_literal: true
require 'rubocop'
require 'rubocop/cops_documentation_generator'
require 'yard'
YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
task.files = ['lib/rubocop/cop/*/*.rb']
task.options = ['--no-output']
end
desc 'Update documentation of all cops'
task update_cops_... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/references.rake | Ruby | mit | 12,856 | master | 909 | # frozen_string_literal: true
namespace :references do
desc 'Verify configuration references availability'
task :verify do |_task|
config = YAML.load_file('config/default.yml', permitted_classes: [Symbol, Regexp])
references = config.values.map do |config_entry|
Array(config_entry.fetch('References',... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/changelog.rake | Ruby | mit | 12,856 | master | 908 | # frozen_string_literal: true
autoload :Changelog, "#{__dir__}/changelog"
namespace :changelog do
%i[new fix change].each do |type|
desc "Create a Changelog entry (#{type})"
task type, [:id] do |_task, args|
ref_type = :pull if args[:id]
path = Changelog::Entry.new(type: type, ref_id: args[:id],... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/prof.rake | Ruby | mit | 12,856 | master | 1,280 | # frozen_string_literal: true
namespace :prof do
dump_path = 'tmp/rubocop-stackprof.dump'
desc 'Run RuboCop on itself with profiling on'
task :run, [:path] do |_task, args|
# Must be run `rubocop` with the local process.
require 'rubocop/server'
if RuboCop::Server.running?
RuboCop::Server::Cli... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/spec_runner.rake | Ruby | mit | 12,856 | master | 5,014 | # frozen_string_literal: true
require_relative '../spec/support/encoding_helper'
require 'rspec/core'
require 'test_queue'
require 'test_queue/runner/rspec'
module TestQueue
# Add `failed_examples` into `TestQueue::Worker` so we can keep
# track of the output for re-running failed examples from RSpec.
class Wor... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/new_cop.rake | Ruby | mit | 12,856 | master | 695 | # frozen_string_literal: true
require 'rubocop'
desc 'Generate a new cop template'
task :new_cop, [:cop] do |_task, args|
cop_name = args.fetch(:cop) do
warn "usage: bundle exec rake 'new_cop[Department/Name]'"
exit!
end
badge = RuboCop::Cop::Badge.parse(cop_name)
generator = RuboCop::Cop::Generator.... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/cut_release.rake | Ruby | mit | 12,856 | master | 3,778 | # frozen_string_literal: true
require 'bump'
namespace :cut_release do
def update_file(path)
content = File.read(path)
File.write(path, yield(content))
end
%w[major minor patch pre].each do |release_type|
desc "Cut a new #{release_type} release, create release notes and update documents."
task ... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/changelog.rb | Ruby | mit | 12,856 | master | 4,661 | # frozen_string_literal: true
# Changelog utility
class Changelog
ENTRIES_PATH = 'changelog/'
FIRST_HEADER = /#{Regexp.escape("## master (unreleased)\n")}/m.freeze
ENTRIES_PATH_TEMPLATE = "#{ENTRIES_PATH}%<type>s_%<name>s_%<timestamp>s.md"
TYPE_REGEXP = /#{Regexp.escape(ENTRIES_PATH)}([a-z]+)_/.freeze
TYPE_T... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/codespell.rake | Ruby | mit | 12,856 | master | 420 | # frozen_string_literal: true
desc 'Run codespell if available'
task :codespell do |_task|
next if Gem.win_platform?
next if ENV['CI'] # CI has its own workflow for this
sh 'which codespell', verbose: false, out: File::NULL, err: File::NULL do |ok, _res|
if ok
sh 'git ls-files --empty-directory | xarg... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | tasks/check_commit.rake | Ruby | mit | 12,856 | master | 815 | # frozen_string_literal: true
def commit_paths(commit_range)
commit_range = "#{commit_range}~..HEAD" if commit_range.include?('..')
`git diff-tree --no-commit-id --name-only -r #{commit_range}`.split("\n")
ensure
exit($CHILD_STATUS.exitstatus) if $CHILD_STATUS.exitstatus != 0
end
desc 'Check files modified in c... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop.rb | Ruby | mit | 12,856 | master | 46,146 | # frozen_string_literal: true
require 'English'
# fileutils is autoloaded by pathname,
# but must be explicitly loaded here for inclusion in `$LOADED_FEATURES`.
require 'fileutils'
before_us = $LOADED_FEATURES.dup
require 'rainbow'
require 'regexp_parser'
require 'set'
require 'stringio'
require 'unicode/display_wi... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/ruby_lsp/rubocop/runtime_adapter.rb | Ruby | mit | 12,856 | master | 3,166 | # frozen_string_literal: true
require_relative '../../rubocop/lsp/runtime'
module RubyLsp
module RuboCop
# Provides an adapter to bridge RuboCop's built-in LSP runtime with Ruby LSP's add-on.
# @api private
class RuntimeAdapter
def initialize(message_queue)
@message_queue = message_queue
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/ruby_lsp/rubocop/addon.rb | Ruby | mit | 12,856 | master | 2,784 | # frozen_string_literal: true
require_relative '../../rubocop'
require_relative '../../rubocop/lsp/logger'
require_relative 'runtime_adapter'
module RubyLsp
module RuboCop
# A Ruby LSP add-on for RuboCop.
class Addon < RubyLsp::Addon
RESTART_WATCHERS = %w[.rubocop.yml .rubocop_todo.yml .rubocop].freez... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/magic_comment.rb | Ruby | mit | 12,856 | master | 9,440 | # frozen_string_literal: true
module RuboCop
# Parse different formats of magic comments.
#
# @abstract parent of three different magic comment handlers
class MagicComment
# IRB's pattern for matching magic comment tokens.
# @see https://github.com/ruby/ruby/blob/b4a55c1/lib/irb/magic-file.rb#L5
TO... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/target_ruby.rb | Ruby | mit | 12,856 | master | 8,415 | # frozen_string_literal: true
module RuboCop
# The kind of Ruby that code inspected by RuboCop is written in.
# @api private
class TargetRuby
KNOWN_RUBIES = [
2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 4.0, 4.1
].freeze
DEFAULT_VERSION = 2.7
OBSOLETE_RUBIES = {
... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/config_obsoletion.rb | Ruby | mit | 12,856 | master | 4,250 | # frozen_string_literal: true
module RuboCop
# This class handles obsolete configuration.
# @api private
class ConfigObsoletion
DEFAULT_RULES_FILE = File.join(ConfigLoader::RUBOCOP_HOME, 'config', 'obsoletion.yml')
COP_RULE_CLASSES = {
'renamed' => RenamedCop,
'removed' => RemovedCop,
'... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/feature_loader.rb | Ruby | mit | 12,856 | master | 2,561 | # frozen_string_literal: true
module RuboCop
# This class handles loading files (a.k.a. features in Ruby) specified
# by `--require` command line option and `require` directive in the config.
#
# Normally, the given string is directly passed to `require`. If a string
# beginning with `.` is given, it is assu... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/comment_config.rb | Ruby | mit | 12,856 | master | 8,130 | # frozen_string_literal: true
module RuboCop
# This class parses the special `rubocop:disable` comments in a source
# and provides a way to check if each cop is enabled at arbitrary line.
class CommentConfig
extend SimpleForwardable
CONFIG_DISABLED_LINE_RANGE_MIN = -Float::INFINITY
# This class pro... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/config_store.rb | Ruby | mit | 12,856 | master | 2,166 | # frozen_string_literal: true
module RuboCop
# Handles caching of configurations and association of inspected
# ruby files to configurations.
class ConfigStore
attr_reader :validated
alias validated? validated
def initialize
# @options_config stores a config that is specified in the command li... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/config.rb | Ruby | mit | 12,856 | master | 14,366 | # frozen_string_literal: true
# FIXME: Moving Rails department code to RuboCop Rails will remove
# the following rubocop:disable comment.
# rubocop:disable Metrics/ClassLength
module RuboCop
# This class represents the configuration of the RuboCop application
# and all its cops. A Config is associated with a YAML ... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/config_loader.rb | Ruby | mit | 12,856 | master | 9,759 | # frozen_string_literal: true
require 'erb'
require 'yaml'
require_relative 'cache_config'
require_relative 'config_finder'
module RuboCop
# Raised when a RuboCop configuration file is not found.
class ConfigNotFoundError < Error
end
# This class represents the configuration of the RuboCop application
# an... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/cli.rb | Ruby | mit | 12,856 | master | 8,057 | # frozen_string_literal: true
require 'fileutils'
module RuboCop
# The CLI is a class responsible of handling all the command line interface
# logic.
class CLI
STATUS_SUCCESS = 0
STATUS_OFFENSES = 1
STATUS_ERROR = 2
STATUS_INTERRUPTED = Signal.list['INT'] + 128
DEFAULT_PARALLEL_... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/file_finder.rb | Ruby | mit | 12,856 | master | 1,114 | # frozen_string_literal: true
require 'pathname'
module RuboCop
# Common methods for finding files.
# @api private
module FileFinder
class << self
attr_accessor :root_level
end
def find_file_upwards(filename, start_dir, stop_dir = nil)
traverse_files_upwards(filename, start_dir, stop_di... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/file_patterns.rb | Ruby | mit | 12,856 | master | 1,243 | # frozen_string_literal: true
module RuboCop
# A wrapper around patterns array to perform optimized search.
#
# For projects with a large set of rubocop todo files, most items in `Exclude`/`Include`
# are exact file names. It is wasteful to linearly check the list of patterns over and over
# to check if the ... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/cops_documentation_generator.rb | Ruby | mit | 12,856 | master | 13,310 | # frozen_string_literal: true
require 'fileutils'
require 'yard'
# Class for generating documentation of all cops departments
# @api private
class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
include ::RuboCop::Cop::Documentation
CopData = Struct.new(
:cop, :description, :example_objects,... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/formatter.rb | Ruby | mit | 12,856 | master | 1,756 | # frozen_string_literal: true
module RuboCop
# The bootstrap module for formatter.
module Formatter
autoload :Colorizable, 'rubocop/formatter/colorizable'
autoload :TextUtil, 'rubocop/formatter/text_util'
autoload :BaseFormatter, 'rubocop/formatter/base_formatter'
autoload :SimpleTextFormatter, 'r... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/remote_config.rb | Ruby | mit | 12,856 | master | 3,099 | # frozen_string_literal: true
require 'net/http'
require 'time'
module RuboCop
# Common methods and behaviors for dealing with remote config files.
# @api private
class RemoteConfig
attr_reader :uri
CACHE_LIFETIME = 24 * 60 * 60
def initialize(url, cache_root)
begin
@uri = URI.parse(... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/error.rb | Ruby | mit | 12,856 | master | 847 | # frozen_string_literal: true
module RuboCop
# An Error exception is different from an Offense with severity 'error'
# When this exception is raised, it means that RuboCop is unable to perform
# a requested action (probably due to misconfiguration) and must stop
# immediately, rather than carrying on
class E... |
github | rubocop/rubocop | https://github.com/rubocop/rubocop | lib/rubocop/platform.rb | Ruby | mit | 12,856 | master | 271 | # frozen_string_literal: true
module RuboCop
# This module provides information on the platform that RuboCop is being run
# on.
module Platform
def self.windows?
/cygwin|mswin|mingw|bccwin|wince|emx/.match?(RbConfig::CONFIG['host_os'])
end
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.