Skip to content

fix: reject plugin names that cannot be a Ruby constant - #80

Merged
tas50 merged 1 commit into
mainfrom
validate-plugin-name
Aug 28, 2026
Merged

tas50 merged 1 commit into
mainfrom
validate-plugin-name

Conversation

@tas50

@tas50 tas50 commented Aug 28, 2026

Copy link
Copy Markdown
Member

fix: reject plugin names that cannot be a Ruby constant

A plugin name becomes three things: a require path, a directory name and a Ruby
constant. Only the last is fussy, and Thor's camel_case folds underscores but
not hyphens -- so a perfectly reasonable busser plugin create my-junit
produced this:

module Busser
  module My-junit
    VERSION = "0.1.0.dev"
  end
end

That is not parseable Ruby. The generator reported every file it wrote, ran
git init, exited 0, and left a project that could not be loaded at all. The
author only found out when they tried to use it.

The name is now validated before anything is written, and the error suggests a
name that would work:

$ busser plugin create my-junit
'my-junit' is not a usable plugin name. A name becomes a Ruby constant, so it
must start with a lowercase letter and contain only lowercase letters, digits
and underscores. Try 'my_junit'.

Eleven specs cover it: five names that must keep working, six that are rejected
-- hyphen, uppercase start, leading digit, space, empty and a path fragment --
plus that nothing is written on rejection and that the suggestion is usable.

A plugin name becomes three things: a require path, a directory name and a Ruby
constant. Only the last is fussy, and Thor's `camel_case` folds underscores but
not hyphens -- so a perfectly reasonable `busser plugin create my-junit`
produced this:

```ruby
module Busser
  module My-junit
    VERSION = "0.1.0.dev"
  end
end
```

That is not parseable Ruby. The generator reported every file it wrote, ran
`git init`, exited 0, and left a project that could not be loaded at all. The
author only found out when they tried to use it.

The name is now validated before anything is written, and the error suggests a
name that would work:

```text
$ busser plugin create my-junit
'my-junit' is not a usable plugin name. A name becomes a Ruby constant, so it
must start with a lowercase letter and contain only lowercase letters, digits
and underscores. Try 'my_junit'.
```

Eleven specs cover it: five names that must keep working, six that are rejected
-- hyphen, uppercase start, leading digit, space, empty and a path fragment --
plus that nothing is written on rejection and that the suggestion is usable.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50
tas50 merged commit bd7ac17 into main Aug 28, 2026
8 checks passed
@tas50
tas50 deleted the validate-plugin-name branch August 28, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant