SketchUp / rubocop-sketchup

Rubocop cops for SketchUp - test against our Extension Warehouse technical requirements and other pitfalls
MIT License
14 stars 8 forks source link

Project/tooling folders (wrongly) assumed to be extension support directories #146

Open asteinarson opened 3 years ago

asteinarson commented 3 years ago

In my VsCode project folder (for my SU extension) I get a Rubocop error: SketchupRequirements/FileStructure reported. When investigating, it shows this cop is finding the '.git/' and '.vscode/' folders and assuming them to be extension support folders.

I'm a bit confused about getting this error as I think many extension developers should be using git and/or VsCode.


Expected behavior

'.git/' and '.vscode/' do not contain Ruby files, and their existence should not raise errors as being additional extension support directories..

Actual behavior

They generate the error (I tested by modifying what the cop prints and have it print out the dir names it finds).

Steps to reproduce the problem

In a valid extension folder, run rubocop (without errors). Then run 'git init'. Rubocop now gives a Sketchup error.

It is likely enough to create an empty directory and touch a 'file.txt' inside that.

RuboCop version

$ [bundle exec] bundle exec rubocop -V
0.93.0 (using Parser 2.7.2.0, rubocop-ast 1.3.0, running on ruby 2.7.0 x86_64-linux-gnu)

RuboCop SketchUp version

0.18

asteinarson commented 3 years ago

One more related note: I tried excluding these two directories using the Exclude mechanism of .rubocop.yml:

AllCops:
  # ... 
  Exclude:
  - src/*/vendor/**/* # Exclude skippy vendor folder
  - .git/
  - .vscode/

However, SketchupRequirements/FileStructure still scans those directories (and reports the error).

thomthom commented 3 years ago

Hi, how have you structured your extension code? Is the root RB and and the support folder at the root of your project?

.gitignore
.rubocop.yml
example.rb
example/main.rb

By default rubocop-sketchup assumes the extension source to be under src. It also assumes that everything in this folder is the extension.

.gitignore
.rubocop.yml
src/example.rb
src/example/main.rb

So if you configured your project to have the source files directly at the root of where the rubocop.yml file is with .vscode etc also there then that will currently be flagged. The cop doesn't take the Exclude list as you say.

I'm not sure if Exclude is appropriate for FileStructure to use to ignore files. Exclude dictates which source files to analyse, but that's different from what files are considered to be part of the extension package.

I think that FileStructure would need a separate option itself for what files to ignore.

thomthom commented 3 years ago

In general I'd recommend keeping the extension sources in a separate sub-directory apart from any tooling. Makes it easier to analyse and package the extension when you don't have to resolve what to ignore.

asteinarson commented 3 years ago

Hi,

Yes, this was the folder structure of my project:

.git
.vscode
.gitignore
.rubocop.yml
example.rb
example/main.rb

I since rearranged the project and can now have the files under src.

I can see taking the exclude directories into account would be some additional work. Maybe a clearer message (in the docs) that the expectation is that all Ruby source files reside under src (I could see it now, in general parts of docs, that expectations is so).

So, it is not as much an issue for me anymore (I was playing around with various project / playground setups when hitting this).