Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Style/PercentLiteralDelimiters:
'%W': '[]'
Style/StringLiterals:
Enabled: false
Style/TrailingComma:
Style/TrailingCommaInLiteral:
Enabled: false
Style/TrailingCommaInArguments:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💄 what do you think about alphabetizing these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, missed this before merging. The file isn't alphabetized
currently – I'll leave that for the next changeset.

On Mon, Apr 18, 2016 at 1:15 PM, Ashley Baldwin-Hunter <
notifications@github.com> wrote:

In .rubocop.yml
#64 (comment)
:

@@ -18,7 +18,9 @@ Style/PercentLiteralDelimiters:
'%W': '[]'
Style/StringLiterals:
Enabled: false
-Style/TrailingComma:
+Style/TrailingCommaInLiteral:

  • Enabled: false
    +Style/TrailingCommaInArguments:

💄 what do you think about alphabetizing these?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/codeclimate/codeclimate-rubocop/pull/64/files/ceaa4cc9a8f1dcb336b1b20237a4a149a7b9ab5d#r60096976

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

Enabled: false
Style/DotPosition:
EnforcedStyle: 'trailing'
Expand Down
14 changes: 8 additions & 6 deletions lib/cc/engine/file_list_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def expanded_list

private

attr_reader :config_store

def absolute_include_paths
@include_paths.map do |path|
begin
Expand All @@ -30,12 +32,12 @@ def absolute_include_paths
end

def rubocop_file_to_include?(file)
if file =~ /\.rb$/
true
else
root, basename = File.split(file)
@config_store.for(root).file_to_include?(basename)
end
root, basename = File.split(file)
store = config_store.for(root)

return false if store.file_to_exclude?(basename)
Copy link
Contributor

@gdiggs gdiggs Apr 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT of formatting these lines

!config_store.file_to_exclude?(basename) &&
  (file =~ /\.rb$/ || store.file_to_include?(basename))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love it. With a negation and both && and || involved in the expression, I prefer to break it apart.


file =~ /\.rb$/ || store.file_to_include?(basename)
end

def rubocop_runner
Expand Down
5 changes: 3 additions & 2 deletions spec/cc/engine/file_list_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ module CC::Engine

it "respects rubocop excludes" do
Dir.chdir(@code) do
create_source_file("Gemfile", "source 'https://rubygems.org'")
create_source_file("src/b.rb", "def a; true; end")
create_source_file("src/c.rb", "def a; true; end")
create_source_file(".rubocop.yml", "AllCops:\n Exclude:\n - src/c.rb")
create_source_file(".rubocop.yml", "AllCops:\n Exclude:\n - src/c.rb\n - Gemfile\n")

resolver = FileListResolver.new(root: @code, engine_config: { "include_paths" => %w[src/] }, config_store: rubocop_config)
resolver = FileListResolver.new(root: @code, engine_config: { "include_paths" => %w[Gemfile src/] }, config_store: rubocop_config)
expect(resolver.expanded_list).to eq [Pathname.new("src/b.rb").realpath.to_s]
end
end
Expand Down