Rubocop Offense: Extensions must have exactly one root Ruby (.rb) file

When I run Rubocop on my extension, I get just one offense:

Inspecting 42 files
Offenses:
RPS_IRender_EW.rb:1:1: E: SketchupRequirements/FileStructure: Extensions must have exactly one root Ruby (.rb) file. Found: 0
42 files inspected, 1 offense detected

What does that mean? Am I perhaps using the wrong version of Rubocop or something?

I have just one base ruby file: RPS_IRender_EW.rb
and all of the other ruby files are in a folder with the same name: “RPS_IRender_EW”

Thanks.

Does the registrar file and the other extension files follow all the recommendations:


P.S. - I surmise that you are Al’s son?

Hi Dan, I’m Al’s brother.

It sure looks to me like everything in our extension follows the recommendations.

Also, as a test, if I make a new folder and put the sample “nn_cuber_maker” files in it from:

https://ruby.sketchup.com/file.extension_requirements.html

nn_cuber_maker.rb
nn_cuber_maker\main.rb

nn_cuber_maker.rb

module NameyNamesson
module CubeMaker
EXTENSION = SketchupExtension.new(“NN Cube Maker”, “nn_cube_maker/main”)
EXTENSION.creator = “Namey Namesson”
EXTENSION.description = “Make cubes in just a few clicks.”
EXTENSION.version = “1.0.0”
EXTENSION.copyright = “2023 Name Namesson”
Sketchup.register_extension(EXTENSION, true)
end
end

nn_cuber_maker/main.rb

module NameyNamesson
module CubeMaker
# Code goes here…
end
end

I still get the same Offense when I run:

rubocop -r rubocop-sketchup --only SketchupRequirements,SketchupDeprecations

in that folder.

I get this:

Inspecting 2 files
E.
Offenses:
nn_cuber_maker.rb:1:1: E: SketchupRequirements/FileStructure: Extensions must have exactly one root Ruby (.rb) file. Found: 0

nn_cuber_maker.rb

^
2 files inspected, 1 offense detected

Note:I did remove the “.rb” file extension from the line:

EXTENSION = SketchupExtension.new(“NN Cube Maker”, "nn_cube_maker/main.rb)

so that Ii wouldn’t get an additional offense about not hard-coding the ruby file name extension.

So I suspect that I’m simply running rubocop wrong, or I have the wrong version of something…
I’m an absolute newbie to trying to use rubocop.

Fisrtly, try and post code correctly in the forum, see:

Yes, I myself do not use it as the rules are often subjective most especially with regard to Ruby core code styling. Its rules file can be tweaked (in yml files) to remove some of the more “nitty” subjective rules.

Normally you run this in a standalone Ruby instance matching what SketchUp runs under (currently Ruby 3.3.2) but I suppose if Ruby 3.x changes are causing issues, then try installing Ruby 2.7.7 and run it under that.

There are quite a few open issues in this gem:

Scanning these quickly, I would suggest ensuring that your code files are encoded as UTF-8 without bit order mark.

I myself always use the magic comment as the 1st line of every code file:

# encoding: UTF-8

… even though (supposedly) after Ruby 2.0 the default script encoding is “UTF-8”
For more information see the introduction explained in the Ruby Script Encoding.
* Note that this paragraph has been removed from Ruby 3.x documentation.


Another possible problem can occur if the wrong properties are chosen when zipping up the RBZ archive. Generally, the built-in Windows context menu “Send to compressed folder” creates good zip files that are accepted by the EW and installable by the SketchUp Extension Manager.

Thanks, Dan.
I’ll try reverting to Ruby 2.7.7 and see if I get different results. I had downloaded and installed Ruby 3.3.6, since it was the latest on their download page.

I use rubocop often with stand-alone Ruby. I used it several times today, and I’ve written and/or modified several .rubocop.yml files.

rubocop-sketchup forces one to have a particular folder structure. It doesn’t work for me.

I use rubocop with SketchUp ruby files, I just don’t use rubocop-sketchup

Lastly, running it with Ruby master and the latest RuboCop, I get all sorts of warnings like:

warning: Inheriting from `RuboCop::Cop::Cop` is deprecated. Use `RuboCop::Cop::Base` instead.
For more information, see https://docs.rubocop.org/rubocop/v1_upgrade_notes.html.