Bug 1803276 - Review Request: rubygem-cane - Provides complexity and style checkers allowing integration with custom metrics
Summary: Review Request: rubygem-cane - Provides complexity and style checkers allowin...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: Package Review
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Nobody's working on this, feel free to take it
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-14 21:51 UTC by Breno
Modified: 2020-03-04 22:01 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-04 22:01:16 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Breno 2020-02-14 21:51:23 UTC
Spec URL: https://raw.githubusercontent.com/skywalkerz0r/rubygem-cane/epel8/rubygem-cane.spec
SRPM URL: https://download.copr.fedorainfracloud.org/results/brandfbb/not-yet-in-epel8/epel-8-x86_64/01240294-rubygem-cane/rubygem-cane-3.0.0-1.el8.src.rpm
Description: Provides complexity and style checkers allowing integration with custom metrics

This package is a requirement for puppet 6.

Using fedora-review you can manually download the packages[1], put them in a directory "deps-dir" and run: 
$ fedora-review -n rubygem-cane  -L ./deps-dir

Thanks.

Fedora Account System Username: brandfbb

1 
https://dl.fedoraproject.org/pub/epel/testing/8/Everything/x86_64/Packages/r/rubygem-redcarpet-3.3.2-17.el8.x86_64.rpm
https://dl.fedoraproject.org/pub/epel/testing/8/Everything/x86_64/Packages/r/rubygem-redcarpet-doc-3.3.2-17.el8.noarch.rpm

Comment 1 Breno 2020-02-23 02:13:44 UTC
Spec URL: https://raw.githubusercontent.com/skywalkerz0r/rubygem-cane/epel8/rubygem-cane.spec
SRPM URL: https://download.copr.fedorainfracloud.org/results/brandfbb/not-yet-in-epel8/epel-8-x86_64/01240294-rubygem-cane/rubygem-cane-3.0.0-1.el8.src.rpm
Description: Provides complexity and style checkers allowing integration with custom metrics

Fedora Account System Username: brandfbb

The package rubygem-redcarpet was pushed to stable.
So the -L option previously mentioned is no longer required.

A regular fedora-review will work.

Thanks.

- B

Comment 2 Adam Borowski 2020-02-24 19:14:28 UTC
The -doc package shouldn't contain fonts.  Here, you ship copies of Lato and SourceCodePro instead of requiring them.

Neither of the packages ship anything in /usr/share/licenses/

Comment 3 Adam Borowski 2020-02-25 00:02:18 UTC
Issues:
=======
- Package contains Requires: ruby(release).


===== MUST items =====

Generic:
[✓]: Package is licensed with an open-source compatible license and meets
     other legal requirements as defined in the legal section of Packaging
     Guidelines.
[✓]: License field in the package spec file matches the actual license.
     Note: Checking patched sources after %prep for licenses. No licenses
     found. Please check the source files for licenses manually.
[!]: License file installed when any subpackage combination is installed.
-- not in /usr/share/licenses/
[ ]: Package contains no bundled libraries without FPC exception.
[✓]: Changelog in prescribed format.
[ ]: Sources contain only permissible code or content.
[-]: Package contains desktop file if it is a GUI application.
[-]: Development files must be in a -devel package
[✓]: Package uses nothing in %doc for runtime.
[✓]: Package consistently uses macros (instead of hard-coded directory
     names).
[✓]: Package is named according to the Package Naming Guidelines.
[✓]: Package does not generate any conflict.
[✓]: Package obeys FHS, except libexecdir and /usr/target.
[-]: If the package is a rename of another package, proper Obsoletes and
     Provides are present.
[✓]: Requires correct, justified where necessary.
[✓]: Spec file is legible and written in American English.
[-]: Package contains systemd file(s) if in need.
[✓]: Package is not known to require an ExcludeArch tag.
[ ]: Package complies to the Packaging Guidelines
[x]: Package successfully compiles and builds into binary rpms on at least
     one supported primary architecture.
[x]: Package installs properly.
[x]: Rpmlint is run on all rpms the build produces.
     Note: There are rpmlint messages (see attachment).
[x]: If (and only if) the source package includes the text of the
     license(s) in its own file, then that file, containing the text of the
     license(s) for the package is included in %license.
[x]: Package requires other packages for directories it uses.
[x]: Package must own all directories that it creates.
[x]: Package does not own files or directories owned by other packages.
[x]: Package uses either %{buildroot} or $RPM_BUILD_ROOT
[x]: Package does not run rm -rf %{buildroot} (or $RPM_BUILD_ROOT) at the
     beginning of %install.
[x]: Macros in Summary, %description expandable at SRPM build time.
[x]: Dist tag is present.
[x]: Package does not contain duplicates in %files.
[x]: Permissions on files are set properly.
[x]: Package must not depend on deprecated() packages.
[x]: Package use %makeinstall only when make install DESTDIR=... doesn't
     work.
[x]: Package is named using only allowed ASCII characters.
[x]: Package does not use a name that already exists.
[x]: Package is not relocatable.
[x]: Sources used to build the package match the upstream source, as
     provided in the spec URL.
[x]: Spec file name must match the spec package %{name}, in the format
     %{name}.spec.
[x]: File names are valid UTF-8.
[x]: Large documentation must go in a -doc subpackage. Large could be size
     (~1MB) or number of files.
     Note: Documentation size is 0 bytes in 0 files.
[x]: Packages must not store files under /srv, /opt or /usr/local

Ruby:
[✓]: Platform dependent files must all go under %{gem_extdir_mri}, platform
     independent under %{gem_dir}.
[x]: Gem package must not define a non-gem subpackage
[x]: Macro %{gem_extdir} is deprecated.
[x]: Gem package is named rubygem-%{gem_name}
[x]: Package contains BuildRequires: rubygems-devel.
[x]: gems should require rubygems package
[x]: Gem package must define %{gem_name} macro.
[x]: Pure Ruby package must be built as noarch
[x]: Package does not contain Requires: ruby(abi).

===== SHOULD items =====

Generic:
[!]: Avoid bundling fonts in non-fonts packages.
     Note: Package contains font files
[✓]: If the source package does not include license text(s) as a separate
     file from upstream, the packager SHOULD query upstream to include it.
[✓]: Final provides and requires are sane (see attachments).
[ ]: Package functions as described.
[✓]: Latest version is packaged.
[✓]: Package does not include license text files separate from upstream.
[-]: Sources are verified with gpgverify first in %prep if upstream
     publishes signatures.
     Note: gpgverify is not used.
[ ]: Description and summary sections in the package spec file contains
     translations for supported Non-English languages, if available.
[-]: Package should compile and build into binary rpms on all supported
     architectures.
[ ]: %check is present and all tests pass.
[!]: Packages should try to preserve timestamps of original installed
     files.
[x]: Reviewer should test that the package builds in mock.
[x]: Buildroot is not present
[x]: Package has no %clean section with rm -rf %{buildroot} (or
     $RPM_BUILD_ROOT)
[x]: No file requires outside of /etc, /bin, /sbin, /usr/bin, /usr/sbin.
[x]: Fully versioned dependency in subpackages if applicable.
[x]: Packager, Vendor, PreReq, Copyright tags should not be in spec file
[x]: Sources can be downloaded from URI in Source: tag
[x]: SourceX is a working URL.
[x]: Spec use %global instead of %define unless justified.

Ruby:
[!]: Test suite of the library should be run.
[x]: Gem package should exclude cached Gem.
[x]: Gem should use %gem_install macro.
[x]: Specfile should use macros from rubygem-devel package.

===== EXTRA items =====

Generic:
[x]: Rpmlint is run on all installed packages.
     Note: There are rpmlint messages (see attachment).
[x]: Spec file according to URL is the same as in SRPM.


Rpmlint
-------
Checking: rubygem-cane-3.0.0-1.el8.noarch.rpm
          rubygem-cane-doc-3.0.0-1.el8.noarch.rpm
          rubygem-cane-3.0.0-1.el8.src.rpm
rubygem-cane.noarch: W: no-manual-page-for-binary cane
3 packages and 0 specfiles checked; 0 errors, 1 warnings.




Rpmlint (installed packages)
----------------------------
rubygem-cane.noarch: W: invalid-url URL: https://github.com/square/cane <urlopen error [Errno -2] Name or service not known>
rubygem-cane.noarch: W: no-manual-page-for-binary cane
rubygem-cane-doc.noarch: W: invalid-url URL: https://github.com/square/cane <urlopen error [Errno -2] Name or service not known>
2 packages and 0 specfiles checked; 0 errors, 3 warnings.



Source checksums
----------------
https://rubygems.org/gems/cane-3.0.0.gem :
  CHECKSUM(SHA256) this package     : 30423ec90a770905643c8b0d5f7c5f740cc8c7814a9bf286c219d24387fac579
  CHECKSUM(SHA256) upstream package : 30423ec90a770905643c8b0d5f7c5f740cc8c7814a9bf286c219d24387fac579


Requires
--------
rubygem-cane (rpmlib, GLIBC filtered):
    /usr/bin/ruby
    ruby
    ruby(rubygems)
    rubygem(parallel)
    rubygem-parallel
    rubygem-rake
    rubygem-rspec
    rubygem-rspec-fire
    rubygem-simplecov
    rubygems

rubygem-cane-doc (rpmlib, GLIBC filtered):
    rubygem-cane
    rubygems



Provides
--------
rubygem-cane:
    rubygem(cane)
    rubygem-cane

rubygem-cane-doc:
    rubygem-cane-doc


That is, issues which I've found:
* no fonts should be included in the -doc package
* the license should be in /usr/share/licenses/rubygem-cane/ (-doc Requires the main package, so it won't need a second copy)
Minor issues:
* no manpage
* timestamps are not preserved (it looks like a ruby toolchain issue?)
I'm not sure about the testsuite issue.

Comment 4 Vít Ondruch 2020-02-25 10:52:01 UTC
(In reply to Adam Borowski from comment #2)
> Neither of the packages ship anything in /usr/share/licenses/

Just FTR, nothing demands to ship anything there. The review guidelines only demands following:

~~~
MUST: If (and only if) the source package includes the text of the license(s) in its own file, then that file, containing the text of the license(s) for the package must be included in %license.
SHOULD: If the source package does not include license text(s) as a separate file from upstream, the packager SHOULD query upstream to include it.
~~~

Comment 5 Vít Ondruch 2020-02-25 11:05:14 UTC
(In reply to Adam Borowski from comment #3)
> I'm not sure about the testsuite issue.

Yes, it would be nice to execute the test suite. Also, I would move the test suite into -doc subpackage, because it is not essential for runtime.

And the Requires declarations should not be required, these are autogenerated.

The HISTORY.md should be marked as a `%doc`, altouhg it is in -doc subpackage.

I don't think the -doc subpackage needs the `BR/R: rubygems`. And it should be noarch.

The `mv %{buildroot}/%{gem_instdir}/bin/* %{buildroot}/%{_bindir}` is definitely wrong. There should be already binary in `%{buildroot}%{_bindir}`.

You don't properly unpack/rebuild/install the gem, as specified in guidelines: https://docs.fedoraproject.org/en-US/packaging-guidelines/Ruby/#_building_gems



All in all, I am not sure what is the source of this package, but I'd say that recent version of rubygem-gem2rpm would provide you better scaffold to polish.

Comment 6 Breno 2020-02-25 16:52:36 UTC
Spec URL: https://raw.githubusercontent.com/skywalkerz0r/rubygem-cane/epel8/rubygem-cane.spec
SRPM URL: https://download.copr.fedorainfracloud.org/results/brandfbb/rubygem-cane-testing/epel-8-x86_64/01252264-rubygem-cane/rubygem-cane-3.0.0-1.el8.src.rpm
Description: Provides complexity and style checkers allowing integration with custom metrics
Fedora Account System Username: brandfbb



The issues should be fixed now.

Comment 7 Vít Ondruch 2020-02-26 09:31:55 UTC
This is a way to execute the test suite:

~~~
--- a/rubygem-cane.spec
+++ b/rubygem-cane.spec
@@ -14,10 +14,7 @@
 BuildRequires: ruby >= 1.9.0
 # for the tests
 BuildRequires: rubygem(parallel)
-# BuildRequires: rubygem(rspec) >= 2.0
-# BuildRequires: rubygem(rspec) < 3
-# BuildRequires: rubygem(simplecov)
-# BuildRequires: rubygem(rspec-fire)
+BuildRequires: rubygem(rspec)
 BuildArch: noarch
 
 %description
@@ -59,6 +56,16 @@
 pushd .%{gem_instdir}
 RUBYOPT="-Ilib/" bin/cane --gte "10,20" | grep "10 is 10.0, should be >= 20.0"
 RUBYOPT="-Ilib/" bin/cane --gte "10,10"
+
+# rspec-fire functionality is now provided by rspec-mocks and is no longer
+# required.
+sed -r -i "/[sS]pec.{1,2}[fF]ire/ s/^/#/" spec/spec_helper.rb
+
+# We don't care about code coverage.
+sed -i "/simplecov/ s/^/#/" spec/spec_helper.rb
+sed -i "/SimpleCov/,/^end/ s/^/#/" spec/spec_helper.rb
+
+rspec spec
 popd
 
 %files
~~~

However, there are two caveats you should solve with upstream:

1. There are two test failures:

~~~
Failures:

  1) Cane::AbcCheck#file_names abc_glob is an array returns an array of relative file paths
     Failure/Error:
       expect(check.send(:file_names)).to eq([
         'spec/fixtures/a/1.rb',
         'spec/fixtures/a/3.prawn',
         'spec/fixtures/b/1.rb'
       ])

       expected: ["spec/fixtures/a/1.rb", "spec/fixtures/a/3.prawn", "spec/fixtures/b/1.rb"]
            got: ["spec/fixtures/a/1.rb", "spec/fixtures/b/1.rb"]

       (compared using ==)
     # ./spec/abc_check_spec.rb:175:in `block (4 levels) in <top (required)>'

  2) Cane::StyleCheck#file_list style_glob is an array returns an array of relative file paths
     Failure/Error:
       expect(check.send(:file_list)).to eq([
         'spec/fixtures/a/1.rb',
         'spec/fixtures/a/3.prawn',
         'spec/fixtures/b/3/i.haml'
       ])

       expected: ["spec/fixtures/a/1.rb", "spec/fixtures/a/3.prawn", "spec/fixtures/b/3/i.haml"]
            got: ["spec/fixtures/a/1.rb"]

       (compared using ==)
     # ./spec/style_check_spec.rb:66:in `block (4 levels) in <top (required)>'

Finished in 0.21902 seconds (files took 0.18891 seconds to load)
89 examples, 2 failures
~~~

Checking the content of the gem, I think the problem is that the test suite is not completely included in the .gem. This line [1] should probably be modified to `gem.test_files = Dir.glob("spec/**/*")` to include every file the test suite needs.

2. The test suite needlessly specified dependency on RSpec 2.x, while it apparently works just fine with the RSpec 3.x. Upstream should relax the dependency. This would also allow to drop the rspec-fire dependency as it is done in the snippet (and it should be done upstream also in the .gemspec file).



And if you will be in contact with upstream, it would be also nice to swap the content of `gemspec.summary` with `gemspec.description`, because typically description is more verbose then summary.

Also, last but not least, it seems Cane upstream suggest to use Rubocop instead of Cane, therefore I wonder why are you trying to include Cane into Fedora?



[1]: https://github.com/square/cane/blob/master/cane.gemspec#L24

Comment 8 Vít Ondruch 2020-02-26 09:34:11 UTC
(In reply to Vít Ondruch from comment #7)
> Also, last but not least, it seems Cane upstream suggest to use Rubocop
> instead of Cane, therefore I wonder why are you trying to include Cane into
> Fedora?

Actually you have already mentioned that:

> This package is a requirement for puppet 6.

But anyway, this appears to be just some linter, is it really necessary? Can the dependency be dropped? It does not appear to be runtime dependency ...

Comment 9 Breno 2020-02-26 14:24:43 UTC
Hi Vít,

Thanks for your feedback regarding the testing.
I will check that with the upstream.


So, regarding the puppet 6 requirement, cane is required by semantic_puppet[1] which is required by puppet.
Does it make sense? Do you think I could handwave it somehow? I am waiting for cane to be included in fedora to ask for a review in a semantic_puppet spec file.

1 https://rubygems.org/gems/semantic_puppet/versions/1.0.2

Comment 10 Vít Ondruch 2020-02-26 15:53:18 UTC
(In reply to Breno from comment #9)
> So, regarding the puppet 6 requirement, cane is required by
> semantic_puppet[1] which is required by puppet.

It seems it is just developement dependency. It will be required just for some test suite run or not even for that case. It can be very likely just ingored or removed as simply as I removed the simplecov dependency in the previous snippet.

> Does it make sense? Do you think I could handwave it somehow? I am waiting
> for cane to be included in fedora to ask for a review in a semantic_puppet
> spec file.

If you plan to introduce more than one package, it is better to submit them in parallel and make the BZ tickets blocking each other. That way, it is better to see what are your reasons. Since if we had this discussion earlier, may be you would save some time packaging rubygem-rspec-fire as well as this one ;)

Comment 11 Breno 2020-03-04 22:01:16 UTC
Thanks for pointing it out Vít.

I am closing this ticket, rubygem-cane doesn't seem to be a runtime dependency for either puppet or puppetserver.


Note You need to log in before you can comment on or make changes to this bug.