Skip to content

Commit

Permalink
rubocop: Lint/LiteralInCondition
Browse files Browse the repository at this point in the history
bwahahahaha!!
  • Loading branch information
mvidner committed Nov 26, 2014
1 parent 2abfe37 commit 097355d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
4 changes: 0 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
inherit_from:
.rubocop_yast_style.yml

# Offense count: 1
Lint/LiteralInCondition:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Lint/UnusedMethodArgument:
Expand Down
25 changes: 2 additions & 23 deletions src/modules/Nfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,34 +269,13 @@ def EscapeSpaces(entries)
end }
end

# (like awk gsub, but return the result, not number of replacements)
# replaces from back!
# @param [String] regex regular expression to replace
# @param [String] replacement the replacement string
# @param [String] s where to replace
# @return the changed string
def gsub(regex, replacement, s)
while true
# argh, regexpsub logs an error if it cannot sub
break if !Builtins.regexpmatch(s, Ops.add(Ops.add(".*", regex), ".*"))
temp = Builtins.regexpsub(
s,
Ops.add(Ops.add("(.*)", regex), "(.*)"),
Ops.add(Ops.add("\\1", replacement), "\\2")
)
break if temp == nil
s = temp
end
s
end

# Un-escape spaces "\\040" -> " "
# @param [String] s string or nil
# @return escaped string or nil
def UnescapeSpaces1(s)
return nil if s.nil?
# escaped space, \040, is /\\040/
# which is "\\\\040"
s == nil ? nil : gsub("\\\\040", " ", s)
s.gsub(/\\040/, " ")
end

# Un-escape spaces "\\040" -> " " in all values of all entries
Expand Down

0 comments on commit 097355d

Please sign in to comment.