Skip to content

Commit

Permalink
rubocop: cleanup Style/GuardClause issue
Browse files Browse the repository at this point in the history
filters/need_kconfig.rb:53:5: C: Style/GuardClause: Use a guard clause (raise Job::SyntaxError, "Wrong syntax of kconfig setting: #{expected_kernel_versions}" if match.nil? || match[:kernel_tag].nil?) instead of wrapping the code inside a conditional expression.
    if match.nil? || match[:kernel_tag].nil?

Signed-off-by: Chen Rong <[email protected]>
Signed-off-by: Philip Li <[email protected]>
  • Loading branch information
xilabao authored and rli9 committed Dec 15, 2021
1 parent b3cb5a9 commit 44728cb
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions filters/need_kconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,25 @@ def kernel_match_version?(kernel_version, expected_kernel_versions)

expected_kernel_versions.all? do |expected_kernel_version|
match = expected_kernel_version.match(/(?<operator>==|!=|<=|>|>=)?\s*(?<kernel_tag>v[0-9]\.\d+(-rc\d+)*)/)
if match.nil? || match[:kernel_tag].nil?
raise Job::SyntaxError, "Wrong syntax of kconfig setting: #{expected_kernel_versions}"
else
operator = match[:operator] || '>='

# rli9 FIXME: hack code to handle <=
# Take below example, MEMORY_HOTPLUG_SPARSE is moved in 5.16-rc1, thus we configure
# as <= 5.15. But we use rc_tag to decide the kernel of commit, 50f9481ed9fb or other
# commit now use kernel v5.15 to compare. This matches the <= and expects MEMORY_HOTPLUG_SPARSE
# is y, which leads to job filtered wrongly on these commits.
#
# fa55b7dcdc43 ("Linux 5.16-rc1")
# c55a04176cba ("Merge tag 'char-misc-5.16-rc1' ...")
# 50f9481ed9fb ("mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE")
# 8bb7eca972ad ("Linux 5.15")
#
# To workaround this, change operator to < to mismatch the kernel
operator = '<' if operator == '<='

kernel_version.method(operator).call(KernelTag.new(match[:kernel_tag]))
end
raise Job::SyntaxError, "Wrong syntax of kconfig setting: #{expected_kernel_versions}" if match.nil? || match[:kernel_tag].nil?

operator = match[:operator] || '>='

# rli9 FIXME: hack code to handle <=
# Take below example, MEMORY_HOTPLUG_SPARSE is moved in 5.16-rc1, thus we configure
# as <= 5.15. But we use rc_tag to decide the kernel of commit, 50f9481ed9fb or other
# commit now use kernel v5.15 to compare. This matches the <= and expects MEMORY_HOTPLUG_SPARSE
# is y, which leads to job filtered wrongly on these commits.
#
# fa55b7dcdc43 ("Linux 5.16-rc1")
# c55a04176cba ("Merge tag 'char-misc-5.16-rc1' ...")
# 50f9481ed9fb ("mm/memory_hotplug: remove CONFIG_MEMORY_HOTPLUG_SPARSE")
# 8bb7eca972ad ("Linux 5.15")
#
# To workaround this, change operator to < to mismatch the kernel
operator = '<' if operator == '<='

kernel_version.method(operator).call(KernelTag.new(match[:kernel_tag]))
end
end

Expand Down

0 comments on commit 44728cb

Please sign in to comment.