increments / qiita-markdown

Qiita-specified markdown processor.
MIT License
394 stars 31 forks source link

Add for Ruby3.x support #116

Closed maedana closed 2 years ago

mziyut commented 2 years ago

https://github.com/increments/qiita-markdown/blob/0a176f025e2babacf3993f15fed3ebfffbbc18be/qiita-markdown.gemspec#L37

On my Ruby v3.1.1 environment, "rubocop" fails when I run bundle exec rake (spec is succeeds). It reason for the failure is that the "rubocop" version listed in the development dependencies of qiita-markdown.gemspec is unsupported version.

warning: parser/current is loading parser/ruby31, which recognizes3.1.2-compliant syntax, but you are running 3.1.1.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Running RuboCop...
.rubocop.yml: Style/PredicateName has the wrong namespace - should be Naming
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
Error: RuboCop found unknown Ruby version 3.1 in `.ruby-version`.
Supported versions: 2.4, 2.5, 2.6, 2.7, 3.0
RuboCop failed!

Is it possible to update the version of "rubocop" (e.g. v1.27.0) as well as "activesupport"?

"rubocop" update will cause a new warning, please temporarily add it to your .rubocop_todo.yml. We will fix it as a separate task.

The execution commands are listed below. https://github.com/increments/qiita-markdown/blob/0a176f025e2babacf3993f15fed3ebfffbbc18be/.rubocop_todo.yml#L1-L2

maedana commented 2 years ago

@mziyut Thank you for your reply. I've fixed the two points you pointed out. I would be happy if you could check them.

Is it possible to update the version of "rubocop" (e.g. v1.27.0) as well as "activesupport"?

I've updated rubocop and .rubocop_todo.yml, but some warnings remain.

❯ bundle exec rubocop                                      
.rubocop.yml: Style/PredicateName has the wrong namespace - should be Naming            
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
Inspecting 47 files                                                                                                    
..............C......C....C....................            

Offenses:                                                                                                              

lib/qiita/markdown/filters/code_block.rb:28:27: C: [Correctable] Style/HashSyntax: Omit the hash value.
                filename: filename,                   
                          ^^^^^^^^                                                                                     
lib/qiita/markdown/filters/code_block.rb:29:27: C: [Correctable] Style/HashSyntax: Omit the hash value.
                language: language,                                                                                    
                          ^^^^^^^^                                                                                     
lib/qiita/markdown/filters/group_mention.rb:65:41: C: [Correctable] Style/HashSyntax: Omit the hash value.
              group = { group_url_name: group_url_name, team_url_name: team_url_name }                                 
                                        ^^^^^^^^^^^^^^     
lib/qiita/markdown/filters/group_mention.rb:65:72: C: [Correctable] Style/HashSyntax: Omit the hash value.                                                                                                                                    
              group = { group_url_name: group_url_name, team_url_name: team_url_name }
                                                                       ^^^^^^^^^^^^^    
lib/qiita/markdown/filters/syntax_highlight.rb:15:35: C: [Correctable] Style/HashSyntax: Omit the hash value.          
                default_language: default_language,                                                                    
                                  ^^^^^^^^^^^^^^^^                                                                     
lib/qiita/markdown/filters/syntax_highlight.rb:16:23: C: [Correctable] Style/HashSyntax: Omit the hash value.                                                                                                                                 
                node: node,                          
                      ^^^^                                 

47 files inspected, 6 offenses detected, 6 offenses auto-correctable                                                   

Tip: Based on detected gems, the following RuboCop extension libraries might be helpful:
  * rubocop-rake (https://rubygems.org/gems/rubocop-rake)
  * rubocop-rspec (https://rubygems.org/gems/rubocop-rspec)                                                            

You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options):
  AllCops:                                                                                                             
    SuggestExtensions: false                         

I think the old style looks fine. So I've added EnforcedShorthandSyntax: never to Style/HashSyntax:. See also https://docs.rubocop.org/rubocop/cops_style.html#stylehashsyntax

 # SupportedShorthandSyntax: always, never, either
 Style/HashSyntax:
   EnforcedStyle: ruby19
+  EnforcedShorthandSyntax: never
mziyut commented 2 years ago

CI is failing because Token cannot be referenced during Fork. We will fix it separately so that CI can be executed when you fork the project.


(Edit) Issue created.

mziyut commented 2 years ago

Released in v0.42.0 (https://github.com/increments/qiita-markdown/pull/119) . Thank you!!

Ref: qiita-markdown | RubyGems.org | your community gem host