gjtorikian / html-proofer

Test your rendered HTML files to make sure they're accurate.
MIT License
1.57k stars 200 forks source link

Runtime error with cache and hydra arguments #779

Closed josunect closed 2 years ago

josunect commented 2 years ago

I was interested in using the hydra argument to decrease the concurrency, as I think this is related to some punctual errors in the execution.

But, when running HTMLProofer with hydra or cache args, I'm getting a runtime error.

Parameters with hydra:

htmlproofer --hydra='{"max_concurrency": 10}' ./public

It results in:

/usr/local/share/gems/gems/html-proofer-5.0.1/lib/html_proofer/configuration.rb:201:in `block (3 levels) in define_options': undefined local variable or method `arg' for #<HTMLProofer::Configuration:0x00007f8df038b488 @options={}> (NameError)

            @options[long_opt_symbol] = parse_json_option("hydra", arg, symbolize_names: false)
                                                                   ^^^
    from /usr/local/share/gems/gems/html-proofer-5.0.1/lib/html_proofer/configuration.rb:253:in `block in set_option'
    from /usr/share/ruby/optparse.rb:1576:in `block in parse_in_order'
    from /usr/share/ruby/optparse.rb:1559:in `catch'
    from /usr/share/ruby/optparse.rb:1559:in `parse_in_order'
    from /usr/share/ruby/optparse.rb:1553:in `order!'
    from /usr/share/ruby/optparse.rb:1659:in `permute!'
    from /usr/share/ruby/optparse.rb:1684:in `parse!'
    from /usr/local/share/gems/gems/html-proofer-5.0.1/lib/html_proofer/configuration.rb:68:in `parse_cli_options'
    from /usr/local/share/gems/gems/html-proofer-5.0.1/lib/html_proofer/cli.rb:14:in `run'
    from /usr/local/share/gems/gems/html-proofer-5.0.1/exe/htmlproofer:14:in `block in <top (required)>'
    from /usr/share/ruby/benchmark.rb:311:in `realtime'
    from /usr/local/share/gems/gems/html-proofer-5.0.1/exe/htmlproofer:14:in `<top (required)>'
    from /usr/local/bin/htmlproofer:25:in `load'
    from /usr/local/bin/htmlproofer:25:in `<main>'

For cache:

htmlproofer --cache='{"timeframe": {"external": "20d"}}' ./public

Result:

gems/html-proofer-5.0.1/lib/html_proofer/configuration.rb:205:in `block (3 levels) in define_options': undefined local variable or method `arg' for #<HTMLProofer::Configuration:0x00007f0edd42b650 @options={}> (NameError)

            @options[long_opt_symbol] = parse_json_option("cache", arg, symbolize_names: false)
                                                                   ^^^
    from /usr/local/share/gems/gems/html-proofer-5.0.1/lib/html_proofer/configuration.rb:253:in `block in set_option'
    from /usr/share/ruby/optparse.rb:1576:in `block in parse_in_order'
    from /usr/share/ruby/optparse.rb:1559:in `catch'
    from /usr/share/ruby/optparse.rb:1559:in `parse_in_order'
    from /usr/share/ruby/optparse.rb:1553:in `order!'
    from /usr/share/ruby/optparse.rb:1659:in `permute!'
    from /usr/share/ruby/optparse.rb:1684:in `parse!'
    from /usr/local/share/gems/gems/html-proofer-5.0.1/lib/html_proofer/configuration.rb:68:in `parse_cli_options'
    from /usr/local/share/gems/gems/html-proofer-5.0.1/lib/html_proofer/cli.rb:14:in `run'
    from /usr/local/share/gems/gems/html-proofer-5.0.1/exe/htmlproofer:14:in `block in <top (required)>'
    from /usr/share/ruby/benchmark.rb:311:in `realtime'
    from /usr/local/share/gems/gems/html-proofer-5.0.1/exe/htmlproofer:14:in `<top (required)>'
    from /usr/local/bin/htmlproofer:25:in `load'
    from /usr/local/bin/htmlproofer:25:in `<main>'

typhoeus seems to be working fine:

htmlproofer --typhoeus '{"connecttimeout": 30, "timeout": 30}' ./public

Results:

Checking 411 external links
Checking 562 internal links
Checking internal link hashes in 0 files
Ran on 103 files!

HTML-Proofer finished successfully.
Finished in 10.98 seconds

Environment

gjtorikian commented 2 years ago

Oof, thanks for reporting this. It was a deadly combination of a typo, and a test suite that was not correct.

josunect commented 2 years ago

Oof, thanks for reporting this. It was a deadly combination of a typo, and a test suite that was not correct.

Thank you!