discourse/script/import_scripts/jive_api.rb
Alan Guo Xiang Tan 35284c77f1
Build(deps-dev): Bump rubocop from 1.66.1 to 1.67.0 (#29226)
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.66.1 to 1.67.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/rubocop/rubocop/releases">rubocop's releases</a>.</em></p>
<blockquote>
<h2>RuboCop 1.67</h2>
<h3>New features</h3>
<ul>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13259">#13259</a>: Add new <code>Lint/DuplicateSetElement</code> cop. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13223">#13223</a>: Add <code>AllowRBSInlineAnnotation</code> config option to <code>Layout/LeadingCommentSpace</code> to support RBS::Inline style annotation comments. ([<a href="https://github.com/tk0miya"><code>@​tk0miya</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13310">#13310</a>: Display analysis Ruby version in <code>rubocop -V</code>. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
</ul>
<h3>Bug fixes</h3>
<ul>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13314">#13314</a>: Fix a false negative for <code>Style/Semicolon</code> when using a semicolon between a closing parenthesis after a line break and a consequent expression. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13217">#13217</a>: Fix a false positive in <code>Lint/ParenthesesAsGroupedExpression</code> with compound ranges. ([<a href="https://github.com/gsamokovarov"><code>@​gsamokovarov</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13268">#13268</a>: Fix a false positive for <code>Style/BlockDelimiters</code> when a single line do-end block with an inline <code>rescue</code> with a semicolon before <code>rescue</code>. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13298">#13298</a>: Fix an error for <code>Layout/AccessModifierIndentation</code> when the access modifier is on the same line as the class definition. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13198">#13198</a>: Fix an error for <code>Style/OneLineConditional</code> when using nested if/then/else/end. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13316">#13316</a>: Fix an incorrect autocorrect for <code>Lint/ImplicitStringConcatenation</code> with <code>Lint/TripleQuotes</code> when string literals with triple quotes are used. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13220">#13220</a>: Fix an incorrect autocorrect for <code>Style/ArgumentsForwarding</code> when using only forwarded arguments in brackets. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13202">#13202</a>: Fix an incorrect autocorrect for <code>Style/CombinableLoops</code> when looping over the same data with different block variable names. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13291">#13291</a>: Fix an incorrect autocorrect for <code>Style/RescueModifier</code> when using modifier rescue for method call with heredoc argument. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13226">#13226</a>: Fix <code>--auto-gen-config</code> when passing an absolute config path. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13225">#13225</a>: Avoid syntax error when correcting <code>Style/OperatorMethodCall</code> with <code>/</code> operations followed by a parenthesized argument. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13235">#13235</a>: Fix an error for <code>Style/IfUnlessModifier</code> when multiline <code>if</code> that fits on one line and using implicit method call with hash value omission syntax. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13219">#13219</a>: Fix a false positive for <code>Style/ArgumentsForwarding</code> with Ruby 3.0 and optional position arguments. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13271">#13271</a>: Fix a false positive for <code>Lint/AmbiguousRange</code> when using rational literals. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13260">#13260</a>: Fix a false positive for <code>Lint/RedundantSafeNavigation</code> with namespaced constants. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13224">#13224</a>: Fix false positives for <code>Style/OperatorMethodCall</code> with named forwarding. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13213">#13213</a>: Fix false positives for <code>Style/AccessModifierDeclarations</code> when <code>AllowModifiersOnAttrs: true</code> and using splat with a percent symbol array, or with a constant. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13145">#13145</a>: Fix false positives for <code>Style/RedundantLineContinuation</code> when line continuations with comparison operator and the LHS is wrapped in parentheses. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/12875">#12875</a>: Fix false positive for <code>Style/ArgumentsForwarding</code> when argument is used inside a block. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13239">#13239</a>: Fix false positive for <code>Style/CollectionCompact</code> when using <code>delete_if</code>. ([<a href="https://github.com/masato-bkn"><code>@​masato-bkn</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13210">#13210</a>: Fix omit_parentheses style for pattern match with value omission in single-line branch. ([<a href="https://github.com/gsamokovarov"><code>@​gsamokovarov</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13149">#13149</a>: Handle crashes in custom Ruby extractors more gracefully. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13319">#13319</a>: Handle literal forward slashes inside a <code>regexp</code> in <code>Lint/LiteralInInterpolation</code>. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13208">#13208</a>: Fix an incorrect autocorrect for <code>Style/IfWithSemicolon</code> when single-line <code>if/;/end</code> when the then body contains a method call with <code>[]</code> or <code>[]=</code>. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13318">#13318</a>: Prevent modifying blocks with <code>Style/HashEachMethods</code> if the hash is modified within the block. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13293">#13293</a>: Fix <code>TargetRubyVersion</code> from a gemspec when the gemspec is not named like the folder it is located in. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13211">#13211</a>: Fix wrong autocorrect for <code>Style/GuardClause</code> when using heredoc without <code>else</code> branch. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13215">#13215</a>: Fix wrong autocorrect for <code>Lint/BigDecimalNew</code> when using <code>::BigDecimal.new</code>. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13215">#13215</a>: Fix wrong autocorrect for <code>Style/MethodCallWithArgsParentheses</code> with <code>EnforcedStyle: omit_parentheses</code> and whitespace. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13302">#13302</a>: Fix incompatible autocorrect between <code>Style/RedundantBegin</code> and <code>Style/BlockDelimiters</code> with <code>EnforcedStyle: braces_for_chaining</code>. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
</ul>
<h3>Changes</h3>
<ul>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13221">#13221</a>: Do not group accessors having RBS::Inline annotation comments in <code>Style/AccessorGrouping</code>. ([<a href="https://github.com/tk0miya"><code>@​tk0miya</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13286">#13286</a>: Add <code>AllowedMethods</code> configuration to <code>Layout/FirstMethodArgumentLineBreak</code>. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13110">#13110</a>: Add support in <code>Style/ArgumentsForwarding</code> for detecting forwarding of all anonymous arguments. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13222">#13222</a>: Allow to write RBS::Inline annotation comments after method definition in <code>Style/CommentedKeyword</code>. ([<a href="https://github.com/tk0miya"><code>@​tk0miya</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13253">#13253</a>: Emit a deprecation when custom cops inherit from <code>RuboCop::Cop::Cop</code>. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13300">#13300</a>: Set <code>EnforcedShorthandSyntax: either</code> by default for <code>Style/HashSyntax</code>. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13254">#13254</a>: Enhance the autocorrect for <code>Naming/InclusiveLanguage</code> when a sole suggestion is set. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13232">#13232</a>: Make server mode aware of auto-restart for local config update. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md">rubocop's changelog</a>.</em></p>
<blockquote>
<h2>1.67.0 (2024-10-15)</h2>
<h3>New features</h3>
<ul>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13259">#13259</a>: Add new <code>Lint/DuplicateSetElement</code> cop. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13223">#13223</a>: Add <code>AllowRBSInlineAnnotation</code> config option to <code>Layout/LeadingCommentSpace</code> to support RBS::Inline style annotation comments. ([<a href="https://github.com/tk0miya"><code>@​tk0miya</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13310">#13310</a>: Display analysis Ruby version in <code>rubocop -V</code>. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
</ul>
<h3>Bug fixes</h3>
<ul>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13314">#13314</a>: Fix a false negative for <code>Style/Semicolon</code> when using a semicolon between a closing parenthesis after a line break and a consequent expression. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13217">#13217</a>: Fix a false positive in <code>Lint/ParenthesesAsGroupedExpression</code> with compound ranges. ([<a href="https://github.com/gsamokovarov"><code>@​gsamokovarov</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13268">#13268</a>: Fix a false positive for <code>Style/BlockDelimiters</code> when a single line do-end block with an inline <code>rescue</code> with a semicolon before <code>rescue</code>. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13298">#13298</a>: Fix an error for <code>Layout/AccessModifierIndentation</code> when the access modifier is on the same line as the class definition. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13198">#13198</a>: Fix an error for <code>Style/OneLineConditional</code> when using nested if/then/else/end. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13316">#13316</a>: Fix an incorrect autocorrect for <code>Lint/ImplicitStringConcatenation</code> with <code>Lint/TripleQuotes</code> when string literals with triple quotes are used. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13220">#13220</a>: Fix an incorrect autocorrect for <code>Style/ArgumentsForwarding</code> when using only forwarded arguments in brackets. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13202">#13202</a>: Fix an incorrect autocorrect for <code>Style/CombinableLoops</code> when looping over the same data with different block variable names. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13291">#13291</a>: Fix an incorrect autocorrect for <code>Style/RescueModifier</code> when using modifier rescue for method call with heredoc argument. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13226">#13226</a>: Fix <code>--auto-gen-config</code> when passing an absolute config path. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13225">#13225</a>: Avoid syntax error when correcting <code>Style/OperatorMethodCall</code> with <code>/</code> operations followed by a parenthesized argument. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13235">#13235</a>: Fix an error for <code>Style/IfUnlessModifier</code> when multiline <code>if</code> that fits on one line and using implicit method call with hash value omission syntax. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13219">#13219</a>: Fix a false positive for <code>Style/ArgumentsForwarding</code> with Ruby 3.0 and optional position arguments. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13271">#13271</a>: Fix a false positive for <code>Lint/AmbiguousRange</code> when using rational literals. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13260">#13260</a>: Fix a false positive for <code>Lint/RedundantSafeNavigation</code> with namespaced constants. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13224">#13224</a>: Fix false positives for <code>Style/OperatorMethodCall</code> with named forwarding. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13213">#13213</a>: Fix false positives for <code>Style/AccessModifierDeclarations</code> when <code>AllowModifiersOnAttrs: true</code> and using splat with a percent symbol array, or with a constant. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13145">#13145</a>: Fix false positives for <code>Style/RedundantLineContinuation</code> when line continuations with comparison operator and the LHS is wrapped in parentheses. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/12875">#12875</a>: Fix false positive for <code>Style/ArgumentsForwarding</code> when argument is used inside a block. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13239">#13239</a>: Fix false positive for <code>Style/CollectionCompact</code> when using <code>delete_if</code>. ([<a href="https://github.com/masato-bkn"><code>@​masato-bkn</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13210">#13210</a>: Fix omit_parentheses style for pattern match with value omission in single-line branch. ([<a href="https://github.com/gsamokovarov"><code>@​gsamokovarov</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13149">#13149</a>: Handle crashes in custom Ruby extractors more gracefully. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13319">#13319</a>: Handle literal forward slashes inside a <code>regexp</code> in <code>Lint/LiteralInInterpolation</code>. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13208">#13208</a>: Fix an incorrect autocorrect for <code>Style/IfWithSemicolon</code> when single-line <code>if/;/end</code> when the then body contains a method call with <code>[]</code> or <code>[]=</code>. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13318">#13318</a>: Prevent modifying blocks with <code>Style/HashEachMethods</code> if the hash is modified within the block. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13293">#13293</a>: Fix <code>TargetRubyVersion</code> from a gemspec when the gemspec is not named like the folder it is located in. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13211">#13211</a>: Fix wrong autocorrect for <code>Style/GuardClause</code> when using heredoc without <code>else</code> branch. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13215">#13215</a>: Fix wrong autocorrect for <code>Lint/BigDecimalNew</code> when using <code>::BigDecimal.new</code>. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13215">#13215</a>: Fix wrong autocorrect for <code>Style/MethodCallWithArgsParentheses</code> with <code>EnforcedStyle: omit_parentheses</code> and whitespace. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13302">#13302</a>: Fix incompatible autocorrect between <code>Style/RedundantBegin</code> and <code>Style/BlockDelimiters</code> with <code>EnforcedStyle: braces_for_chaining</code>. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
</ul>
<h3>Changes</h3>
<ul>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13221">#13221</a>: Do not group accessors having RBS::Inline annotation comments in <code>Style/AccessorGrouping</code>. ([<a href="https://github.com/tk0miya"><code>@​tk0miya</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13286">#13286</a>: Add <code>AllowedMethods</code> configuration to <code>Layout/FirstMethodArgumentLineBreak</code>. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/issues/13110">#13110</a>: Add support in <code>Style/ArgumentsForwarding</code> for detecting forwarding of all anonymous arguments. ([<a href="https://github.com/dvandersluis"><code>@​dvandersluis</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13222">#13222</a>: Allow to write RBS::Inline annotation comments after method definition in <code>Style/CommentedKeyword</code>. ([<a href="https://github.com/tk0miya"><code>@​tk0miya</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13253">#13253</a>: Emit a deprecation when custom cops inherit from <code>RuboCop::Cop::Cop</code>. ([<a href="https://github.com/earlopain"><code>@​earlopain</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13300">#13300</a>: Set <code>EnforcedShorthandSyntax: either</code> by default for <code>Style/HashSyntax</code>. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
<li><a href="https://redirect.github.com/rubocop/rubocop/pull/13254">#13254</a>: Enhance the autocorrect for <code>Naming/InclusiveLanguage</code> when a sole suggestion is set. ([<a href="https://github.com/koic"><code>@​koic</code></a>][])</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="c108ac0822"><code>c108ac0</code></a> Cut 1.67</li>
<li><a href="74ddd9bb96"><code>74ddd9b</code></a> Update Changelog</li>
<li><a href="b5c12aea89"><code>b5c12ae</code></a> Update Changelog</li>
<li><a href="c936160665"><code>c936160</code></a> [Fix <a href="https://redirect.github.com/rubocop/rubocop/issues/13331">#13331</a>] Fix an error when using release task</li>
<li><a href="60ecb00dd7"><code>60ecb00</code></a> [Fix <a href="https://redirect.github.com/rubocop/rubocop/issues/13328">#13328</a>] Declare <code>Enabled</code> as a common config key</li>
<li><a href="99022d9880"><code>99022d9</code></a> Merge pull request <a href="https://redirect.github.com/rubocop/rubocop/issues/13327">#13327</a> from koic/make_server_mode_aware_of_auto_restart_fo...</li>
<li><a href="60432f5e44"><code>60432f5</code></a> Apply <code>RESTRICT_ON_SEND</code> to <code>Bundler/GemVersion</code></li>
<li><a href="6b31c39f1e"><code>6b31c39</code></a> Make server mode aware of auto-restart for .rubocop_todo.yml update</li>
<li><a href="adb7ceed43"><code>adb7cee</code></a> [Fix <a href="https://redirect.github.com/rubocop/rubocop/issues/9816">#9816</a>] Refine <code>Lint/SafeNavigationConsistency</code></li>
<li><a href="7d6797cf9d"><code>7d6797c</code></a> [Fix <a href="https://redirect.github.com/rubocop/rubocop/issues/13286">#13286</a>] Add <code>AllowedMethods</code> and <code>AllowedPatterns</code> configuration to `Lay...</li>
<li>Additional commits viewable in <a href="https://github.com/rubocop/rubocop/compare/v1.66.1...v1.67.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rubocop&package-manager=bundler&previous-version=1.66.1&new-version=1.67.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
2024-10-16 10:56:58 +08:00

511 lines
14 KiB
Ruby

# frozen_string_literal: true
require "nokogiri"
require "htmlentities"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
# https://developers.jivesoftware.com/api/v3/cloud/rest/index.html
class ImportScripts::JiveApi < ImportScripts::Base
USER_COUNT ||= 1000
POST_COUNT ||= 100
STAFF_GUARDIAN ||= Guardian.new(Discourse.system_user)
TO_IMPORT ||= [
#############################
# WHOLE CATEGORY OF CONTENT #
#############################
# Announcement & News
{
jive_object: {
type: 37,
id: 1004,
},
filters: {
created_after: 1.year.ago,
type: "post",
},
category_id: 7,
},
# Questions & Answers / General Discussions
{
jive_object: {
type: 14,
id: 2006,
},
filters: {
created_after: 6.months.ago,
type: "discussion",
},
category: Proc.new { |c| c["question"] ? 5 : 21 },
},
# Anywhere beta
{
jive_object: {
type: 14,
id: 2052,
},
filters: {
created_after: 6.months.ago,
type: "discussion",
},
category_id: 22,
},
# Tips & Tricks
{ jive_object: { type: 37, id: 1284 }, filters: { type: "post" }, category_id: 6 },
{ jive_object: { type: 37, id: 1319 }, filters: { type: "post" }, category_id: 6 },
{ jive_object: { type: 37, id: 1177 }, filters: { type: "post" }, category_id: 6 },
{ jive_object: { type: 37, id: 1165 }, filters: { type: "post" }, category_id: 6 },
# Ambassadors
{
jive_object: {
type: 700,
id: 1001,
},
filters: {
type: "discussion",
},
authenticated: true,
category_id: 8,
},
# Experts
{
jive_object: {
type: 700,
id: 1034,
},
filters: {
type: "discussion",
},
authenticated: true,
category_id: 15,
},
# Feature Requests
{ jive_object: { type: 14, id: 2015 }, filters: { type: "idea" }, category_id: 31 },
####################
# SELECTED CONTENT #
####################
# Announcement & News
{
jive_object: {
type: 37,
id: 1004,
},
filters: {
entities: {
38 => [1345, 1381, 1845, 2046, 2060, 2061],
},
},
category_id: 7,
},
# Problem Solving
{
jive_object: {
type: 14,
id: 2006,
},
filters: {
entities: {
2 => [
116_685,
160_745,
177_010,
223_482,
225_036,
233_228,
257_882,
285_103,
292_297,
345_243,
363_250,
434_546,
],
},
},
category_id: 10,
},
# General Discussions
{
jive_object: {
type: 14,
id: 2006,
},
filters: {
entities: {
2 => [178_203, 188_350, 312_734],
},
},
category_id: 21,
},
# Questions & Answers
{
jive_object: {
type: 14,
id: 2006,
},
filters: {
entities: {
2 => [418_811],
},
},
category_id: 5,
},
]
def initialize
super
@base_uri = ENV["BASE_URI"]
@username = ENV["USERNAME"]
@password = ENV["PASSWORD"]
@htmlentities = HTMLEntities.new
end
def execute
update_existing_users
import_users
import_contents
import_bookmarks
mark_topics_as_solved
end
def update_existing_users
puts "", "updating existing users..."
# we just need to do this once
return if User.human_users.limit(101).count > 100
User.human_users.find_each do |user|
people = get("people/email/#{user.email}?fields=initialLogin,-resources", true)
if people && people["initialLogin"].present?
created_at = DateTime.parse(people["initialLogin"])
user.update_columns(created_at: created_at) if user.created_at > created_at
end
end
end
def import_users
puts "", "importing users..."
imported_users = 0
start_index = [0, UserCustomField.where(name: "import_id").count - USER_COUNT].max
loop do
users =
get(
"people/@all?fields=initialLogin,emails,displayName,mentionName,thumbnailUrl,-resources&count=#{USER_COUNT}&startIndex=#{start_index}",
true,
)
create_users(users["list"], offset: imported_users) do |user|
{
id: user["id"],
created_at: user["initialLogin"],
email: user["emails"].find { |email| email["primary"] }["value"],
username: user["mentionName"],
name: user["displayName"],
avatar_url: user["thumbnailUrl"],
}
end
break if users["list"].size < USER_COUNT || users.dig("links", "next").blank?
imported_users += users["list"].size
break unless start_index = users["links"]["next"][/startIndex=(\d+)/, 1]
end
end
def import_contents
puts "", "importing contents..."
TO_IMPORT.each do |to_import|
puts Time.now
entity = to_import[:jive_object]
places =
get(
"places?fields=placeID,name,-resources&filter=entityDescriptor(#{entity[:type]},#{entity[:id]})",
to_import[:authenticated],
)
import_place_contents(places["list"][0], to_import) if places && places["list"].present?
end
end
def import_place_contents(place, to_import)
puts "", "importing contents for '#{place["name"]}'..."
start_index = 0
if to_import.dig(:filters, :entities).present?
path = "contents"
entities =
to_import[:filters][:entities].flat_map { |type, ids| ids.map { |id| "#{type},#{id}" } }
filters = "filter=entityDescriptor(#{entities.join(",")})"
else
path = "places/#{place["placeID"]}/contents"
filters = +"filter=status(published)"
if to_import[:filters]
if to_import[:filters][:type].present?
filters << "&filter=type(#{to_import[:filters][:type]})"
end
if to_import[:filters][:created_after].present?
filters << "&filter=creationDate(null,#{to_import[:filters][:created_after].strftime("%Y-%m-%dT%TZ")})"
end
end
end
loop do
contents =
get(
"#{path}?#{filters}&sort=dateCreatedAsc&count=#{POST_COUNT}&startIndex=#{start_index}",
to_import[:authenticated],
)
contents["list"].each do |content|
content_id = content["contentID"].presence || "#{content["type"]}_#{content["id"]}"
custom_fields = { import_id: content_id }
custom_fields[:import_permalink] = content["permalink"] if content["permalink"].present?
topic = {
id: content_id,
created_at: content["published"],
title: @htmlentities.decode(content["subject"]),
raw: process_raw(content["content"]["text"]),
user_id:
user_id_from_imported_user_id(content["author"]["id"]) || Discourse::SYSTEM_USER_ID,
views: content["viewCount"],
custom_fields: custom_fields,
}
if to_import[:category]
topic[:category] = to_import[:category].call(content)
else
topic[:category] = to_import[:category_id]
end
post_id = post_id_from_imported_post_id(topic[:id])
parent_post = post_id ? Post.unscoped.find_by(id: post_id) : create_post(topic, topic[:id])
if parent_post&.id && parent_post.topic_id
resources = content["resources"]
if content["likeCount"].to_i > 0 && resources.dig("likes", "ref").present?
import_likes(resources["likes"]["ref"], parent_post.id)
end
if content["replyCount"].to_i > 0
if resources.dig("comments", "ref").present?
import_comments(resources["comments"]["ref"], parent_post.topic_id, to_import)
end
if resources.dig("messages", "ref").present?
import_messages(resources["messages"]["ref"], parent_post.topic_id, to_import)
end
end
end
end
break if contents["list"].size < POST_COUNT || contents.dig("links", "next").blank?
break unless start_index = contents["links"]["next"][/startIndex=(\d+)/, 1]
end
end
def import_likes(url, post_id)
start_index = 0
loop do
likes = get("#{url}?&count=#{USER_COUNT}&startIndex=#{start_index}", true)
break if likes["error"]
likes["list"].each do |like|
next unless user_id = user_id_from_imported_user_id(like["id"])
PostActionCreator.like(User.find(user_id), Post.find(post_id))
end
break if likes["list"].size < USER_COUNT || likes.dig("links", "next").blank?
break unless start_index = likes["links"]["next"][/startIndex=(\d+)/, 1]
end
end
def import_comments(url, topic_id, to_import)
start_index = 0
loop do
comments =
get(
"#{url}?hierarchical=false&count=#{POST_COUNT}&startIndex=#{start_index}",
to_import[:authenticated],
)
break if comments["error"]
comments["list"].each do |comment|
next if post_id_from_imported_post_id(comment["id"])
post = {
id: comment["id"],
created_at: comment["published"],
topic_id: topic_id,
user_id:
user_id_from_imported_user_id(comment["author"]["id"]) || Discourse::SYSTEM_USER_ID,
raw: process_raw(comment["content"]["text"]),
custom_fields: {
import_id: comment["id"],
},
}
if (parent_post_id = comment["parentID"]).to_i > 0
if parent = topic_lookup_from_imported_post_id(parent_post_id)
post[:reply_to_post_number] = parent[:post_number]
end
end
if created_post = create_post(post, post[:id])
if comment["likeCount"].to_i > 0 && comment.dig("resources", "likes", "ref").present?
import_likes(comment["resources"]["likes"]["ref"], created_post.id)
end
end
end
break if comments["list"].size < POST_COUNT || comments.dig("links", "next").blank?
break unless start_index = comments["links"]["next"][/startIndex=(\d+)/, 1]
end
end
def import_messages(url, topic_id, to_import)
start_index = 0
loop do
messages =
get(
"#{url}?hierarchical=false&count=#{POST_COUNT}&startIndex=#{start_index}",
to_import[:authenticated],
)
break if messages["error"]
messages["list"].each do |message|
next if post_id_from_imported_post_id(message["id"])
post = {
id: message["id"],
created_at: message["published"],
topic_id: topic_id,
user_id:
user_id_from_imported_user_id(message["author"]["id"]) || Discourse::SYSTEM_USER_ID,
raw: process_raw(message["content"]["text"]),
custom_fields: {
import_id: message["id"],
},
}
post[:custom_fields][:is_accepted_answer] = true if message["answer"]
if (parent_post_id = message["parentID"].to_i) > 0
if parent = topic_lookup_from_imported_post_id(parent_post_id)
post[:reply_to_post_number] = parent[:post_number]
end
end
if created_post = create_post(post, post[:id])
if message["likeCount"].to_i > 0 && message.dig("resources", "likes", "ref").present?
import_likes(message["resources"]["likes"]["ref"], created_post.id)
end
end
end
break if messages["list"].size < POST_COUNT || messages.dig("links", "next").blank?
break unless start_index = messages["links"]["next"][/startIndex=(\d+)/, 1]
end
end
def create_post(options, import_id)
post = super(options, import_id)
if Post === post
add_post(import_id, post)
add_topic(post)
end
post
end
def import_bookmarks
puts "", "importing bookmarks..."
start_index = 0
fields =
"fields=author.id,favoriteObject.id,-resources,-author.resources,-favoriteObject.resources"
filter = "&filter=creationDate(null,2016-01-01T00:00:00Z)"
loop do
favorites =
get(
"contents?#{fields}&filter=type(favorite)#{filter}&sort=dateCreatedAsc&count=#{POST_COUNT}&startIndex=#{start_index}",
)
bookmarks_to_create =
favorites["list"]
.map do |favorite|
next unless user_id = user_id_from_imported_user_id(favorite["author"]["id"])
next unless post_id = post_id_from_imported_post_id(favorite["favoriteObject"]["id"])
{ user_id: user_id, post_id: post_id }
end
.flatten
create_bookmarks(bookmarks_to_create) { |row| row }
break if favorites["list"].size < POST_COUNT || favorites.dig("links", "next").blank?
break unless start_index = favorites["links"]["next"][/startIndex=(\d+)/, 1]
end
end
def process_raw(raw)
doc = Nokogiri::HTML5.fragment(raw)
# convert emoticon
doc
.css("span.emoticon-inline")
.each do |span|
name = span["class"][/emoticon_(\w+)/, 1]&.downcase
name && Emoji.exists?(name) ? span.replace(":#{name}:") : span.remove
end
# convert mentions
doc.css("a.jive-link-profile-small").each { |a| a.replace("@#{a.content}") }
# fix links
doc
.css("a[href]")
.each do |a|
if a["href"]["#{@base_uri}/docs/DOC-"]
a["href"] = a["href"][%r{#{Regexp.escape(@base_uri)}/docs/DOC-\d+}]
elsif a["href"][@base_uri]
a.replace(a.inner_html)
end
end
html = doc.at(".jive-rendered-content").to_html
HtmlToMarkdown.new(html, keep_img_tags: true).to_markdown
end
def mark_topics_as_solved
puts "", "Marking topics as solved..."
DB.exec <<~SQL
INSERT INTO topic_custom_fields (name, value, topic_id, created_at, updated_at)
SELECT 'accepted_answer_post_id', pcf.post_id, p.topic_id, p.created_at, p.created_at
FROM post_custom_fields pcf
JOIN posts p ON p.id = pcf.post_id
WHERE pcf.name = 'is_accepted_answer'
SQL
end
def get(url_or_path, authenticated = false)
tries ||= 3
command = %w[curl --silent]
command << "--user \"#{@username}:#{@password}\"" if !!authenticated
command << (
if url_or_path.start_with?("http")
"\"#{url_or_path}\""
else
"\"#{@base_uri}/api/core/v3/#{url_or_path}\""
end
)
puts command.join(" ") if ENV["VERBOSE"] == "1"
JSON.parse `#{command.join(" ")}`
rescue StandardError
retry if (tries -= 1) >= 0
end
end
ImportScripts::JiveApi.new.perform