From 5a9e135159ec0fd3f1910e0813b43afc626033f2 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 13:17:46 +0100 Subject: [PATCH 01/40] Generated a Rubocop config rubocop --auto-gen-config --- .rubocop.yml | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..b1766e9 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,208 @@ +# This configuration was generated by `rubocop --auto-gen-config` +# on 2014-11-26 13:17:00 +0100 using RuboCop version 0.26.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +Lint/LiteralInCondition: + Enabled: false + +# Offense count: 3 +Lint/Loop: + Enabled: false + +# Offense count: 3 +Lint/UnderscorePrefixedVariableName: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/UnusedMethodArgument: + Enabled: false + +# Offense count: 9 +Lint/UselessAssignment: + Enabled: false + +# Offense count: 4 +Metrics/BlockNesting: + Max: 4 + +# Offense count: 5 +# Configuration parameters: CountComments. +Metrics/ClassLength: + Max: 521 + +# Offense count: 13 +Metrics/CyclomaticComplexity: + Max: 30 + +# Offense count: 56 +# Configuration parameters: AllowURI, URISchemes. +Metrics/LineLength: + Max: 135 + +# Offense count: 46 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 222 + +# Offense count: 13 +Metrics/PerceivedComplexity: + Max: 34 + +# Offense count: 2 +# Cop supports --auto-correct. +Style/BlockEndNewline: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/Blocks: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/BracesAroundHashParameters: + Enabled: false + +# Offense count: 3 +# Configuration parameters: Keywords. +Style/CommentAnnotation: + Enabled: false + +# Offense count: 20 +Style/Documentation: + Enabled: false + +# Offense count: 9 +# Cop supports --auto-correct. +Style/EmptyLines: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/EmptyLinesAroundBody: + Enabled: false + +# Offense count: 9 +# Configuration parameters: Exclude. +Style/FileName: + Enabled: false + +# Offense count: 91 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles. +Style/HashSyntax: + EnforcedStyle: hash_rockets + +# Offense count: 1 +# Configuration parameters: MaxLineLength. +Style/IfUnlessModifier: + Enabled: false + +# Offense count: 10 +# Cop supports --auto-correct. +Style/IndentationConsistency: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/IndentationWidth: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/InfiniteLoop: + Enabled: false + +# Offense count: 81 +Style/Lambda: + Enabled: false + +# Offense count: 20 +# Cop supports --auto-correct. +Style/LeadingCommentSpace: + Enabled: false + +# Offense count: 27 +# Cop supports --auto-correct. +Style/LineEndConcatenation: + Enabled: false + +# Offense count: 61 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/MethodName: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/MultilineBlockLayout: + Enabled: false + +# Offense count: 4 +Style/MultilineTernaryOperator: + Enabled: false + +# Offense count: 12 +# Cop supports --auto-correct. +Style/NegatedIf: + Enabled: false + +# Offense count: 11 +# Cop supports --auto-correct. +Style/NilComparison: + Enabled: false + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: IncludeSemanticChanges. +Style/NonNilCheck: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/SpaceAfterNot: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/SpaceBeforeBlockBraces: + Enabled: false + +# Offense count: 1269 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/StringLiterals: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. +Style/TrailingComma: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +Style/TrailingWhitespace: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist. +Style/TrivialAccessors: + Enabled: false + +# Offense count: 40 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/VariableName: + Enabled: false + +# Offense count: 16 +# Cop supports --auto-correct. +Style/WordArray: + MinSize: 29 From ce8b5b3d8da681627cce90dd47c012138a9fd5ed Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 13:51:38 +0100 Subject: [PATCH 02/40] rubocop: SUSE style is double quotes --- .rubocop.yml | 9 +++------ .rubocop_yast_style.yml | 8 ++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .rubocop_yast_style.yml diff --git a/.rubocop.yml b/.rubocop.yml index b1766e9..948fc35 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,6 +5,9 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +inherit_from: + .rubocop_yast_style.yml + # Offense count: 1 Lint/LiteralInCondition: Enabled: false @@ -174,12 +177,6 @@ Style/SpaceAfterNot: Style/SpaceBeforeBlockBraces: Enabled: false -# Offense count: 1269 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/StringLiterals: - Enabled: false - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. diff --git a/.rubocop_yast_style.yml b/.rubocop_yast_style.yml new file mode 100644 index 0000000..d349547 --- /dev/null +++ b/.rubocop_yast_style.yml @@ -0,0 +1,8 @@ +# Rubocop style configuration +# +# Following +# https://github.com/SUSE/style-guides/blob/master/Ruby.md + +# https://github.com/SUSE/style-guides/blob/master/Ruby.md#strings +Style/StringLiterals: + EnforcedStyle: double_quotes From 3fe22777e2dbd28bb8380cee68e9b25eccc64a3a Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 13:52:59 +0100 Subject: [PATCH 03/40] rubocop: hash_rockets as produced by YCP Killer --- .rubocop.yml | 6 ------ .rubocop_yast_style.yml | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 948fc35..6cf0dd6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -96,12 +96,6 @@ Style/EmptyLinesAroundBody: Style/FileName: Enabled: false -# Offense count: 91 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles. -Style/HashSyntax: - EnforcedStyle: hash_rockets - # Offense count: 1 # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: diff --git a/.rubocop_yast_style.yml b/.rubocop_yast_style.yml index d349547..62524eb 100644 --- a/.rubocop_yast_style.yml +++ b/.rubocop_yast_style.yml @@ -6,3 +6,8 @@ # https://github.com/SUSE/style-guides/blob/master/Ruby.md#strings Style/StringLiterals: EnforcedStyle: double_quotes + +# YCP Killer used rockets +Style/HashSyntax: + EnforcedStyle: hash_rockets + From d677058fa5dcbb2a47dc25d90acdadaf4e4ca831 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 13:57:50 +0100 Subject: [PATCH 04/40] rubocop: fixed Style/Lambda --- .rubocop.yml | 4 ---- src/include/nfs/wizards.rb | 6 +++--- testsuite/tests/autoyast.rb | 10 +++++----- testsuite/tests/escape.rb | 34 +++++++++++++++++----------------- testsuite/tests/nfs-options.rb | 24 ++++++++++++------------ testsuite/tests/r-check.rb | 26 +++++++++++++------------- testsuite/tests/r-fstab.rb | 18 +++++++++--------- testsuite/tests/r-spec.rb | 14 +++++++------- testsuite/tests/r-strip.rb | 8 ++++---- testsuite/tests/readwrite.rb | 6 +++--- testsuite/tests/readwrite2.rb | 16 ++++++++-------- 11 files changed, 81 insertions(+), 85 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 6cf0dd6..ac96a3c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -116,10 +116,6 @@ Style/IndentationWidth: Style/InfiniteLoop: Enabled: false -# Offense count: 81 -Style/Lambda: - Enabled: false - # Offense count: 20 # Cop supports --auto-correct. Style/LeadingCommentSpace: diff --git a/src/include/nfs/wizards.rb b/src/include/nfs/wizards.rb index 9276aa2..ae360c2 100644 --- a/src/include/nfs/wizards.rb +++ b/src/include/nfs/wizards.rb @@ -30,9 +30,9 @@ def MainSequence # @return sequence result def NfsSequence aliases = { - "read" => [lambda { ReadDialog() }, true], - "main" => lambda { MainSequence() }, - "write" => [lambda { WriteDialog() }, true] + "read" => [->() { ReadDialog() }, true], + "main" => ->() { MainSequence() }, + "write" => [->() { WriteDialog() }, true] } sequence = { diff --git a/testsuite/tests/autoyast.rb b/testsuite/tests/autoyast.rb index ee45244..486ef81 100644 --- a/testsuite/tests/autoyast.rb +++ b/testsuite/tests/autoyast.rb @@ -28,7 +28,7 @@ def main "nfs_options" => "defaults" } - TEST(lambda { Nfs.ImportAny([@entry1]) }, [@READ, {}, {}], nil) + TEST(->() { Nfs.ImportAny([@entry1]) }, [@READ, {}, {}], nil) Assert.Equal(1, Builtins.size(Nfs.nfs_entries)) Assert.Equal( "data.example.com:/mirror", @@ -50,7 +50,7 @@ def main # --------- DUMP("- empty") - TEST(lambda { Nfs.ImportAny([]) }, [@READ, {}, {}], nil) + TEST(->() { Nfs.ImportAny([]) }, [@READ, {}, {}], nil) Assert.Equal(0, Builtins.size(Nfs.nfs_entries)) # --------- @@ -66,7 +66,7 @@ def main "enable_nfs4" => true, "idmapd_domain" => "example.com" } - TEST(lambda { Nfs.ImportAny([@global_options, @entry1]) }, [@READ, {}, {}], nil) + TEST(->() { Nfs.ImportAny([@global_options, @entry1]) }, [@READ, {}, {}], nil) Assert.Equal(true, Nfs.nfs4_enabled) Assert.Equal("example.com", Nfs.idmapd_domain) Assert.Equal(1, Builtins.size(Nfs.nfs_entries)) @@ -98,7 +98,7 @@ def main "vfstype" => "nfs4" } - TEST(lambda { Nfs.ImportAny([@global_options2, @entry2]) }, [@READ, {}, {}], nil) + TEST(->() { Nfs.ImportAny([@global_options2, @entry2]) }, [@READ, {}, {}], nil) Assert.Equal(true, Nfs.nfs4_enabled) Assert.Equal("example.com", Nfs.idmapd_domain) @@ -128,7 +128,7 @@ def main "enable_nfs_gss" => true, "idmapd_domain" => "example.com" } - TEST(lambda { Nfs.ImportAny([@global_options, @entry1]) }, [@READ, {}, {}], nil) + TEST(->() { Nfs.ImportAny([@global_options, @entry1]) }, [@READ, {}, {}], nil) # assertions shortened Assert.Equal(true, Nfs.nfs_gss_enabled) Assert.Equal(1, Builtins.size(Nfs.nfs_entries)) diff --git a/testsuite/tests/escape.rb b/testsuite/tests/escape.rb index 4478e49..04f2d6e 100644 --- a/testsuite/tests/escape.rb +++ b/testsuite/tests/escape.rb @@ -25,37 +25,37 @@ def main Yast.import "Nfs" DUMP("Nfs::EscapeSpaces1 normative") - TEST(lambda { Nfs.EscapeSpaces1(nil) }, [], nil) - TEST(lambda { Nfs.EscapeSpaces1("") }, [], nil) - TEST(lambda { Nfs.EscapeSpaces1(" ") }, [], nil) - TEST(lambda { Nfs.EscapeSpaces1(" ") }, [], nil) - TEST(lambda { Nfs.EscapeSpaces1("nospaces") }, [], nil) - TEST(lambda { Nfs.EscapeSpaces1("one space") }, [], nil) - TEST(lambda { Nfs.EscapeSpaces1(" before, two, after ") }, [], nil) + TEST(->() { Nfs.EscapeSpaces1(nil) }, [], nil) + TEST(->() { Nfs.EscapeSpaces1("") }, [], nil) + TEST(->() { Nfs.EscapeSpaces1(" ") }, [], nil) + TEST(->() { Nfs.EscapeSpaces1(" ") }, [], nil) + TEST(->() { Nfs.EscapeSpaces1("nospaces") }, [], nil) + TEST(->() { Nfs.EscapeSpaces1("one space") }, [], nil) + TEST(->() { Nfs.EscapeSpaces1(" before, two, after ") }, [], nil) DUMP("Nfs::EscapeSpaces1 informative") # weird characters # TEST cuts it off at the newline :( - TEST(lambda { Nfs.EscapeSpaces1("'\"\\\n") }, [], nil) + TEST(->() { Nfs.EscapeSpaces1("'\"\\\n") }, [], nil) # see how it works when applied multiple times - TEST(lambda { Nfs.EscapeSpaces1(Nfs.EscapeSpaces1(" ")) }, [], nil) + TEST(->() { Nfs.EscapeSpaces1(Nfs.EscapeSpaces1(" ")) }, [], nil) DUMP("Nfs::UnescapeSpaces1 normative") - TEST(lambda { Nfs.UnescapeSpaces1(nil) }, [], nil) - TEST(lambda { Nfs.UnescapeSpaces1("") }, [], nil) - TEST(lambda { Nfs.UnescapeSpaces1("\\040") }, [], nil) - TEST(lambda { Nfs.UnescapeSpaces1("\\040\\040") }, [], nil) - TEST(lambda { Nfs.UnescapeSpaces1("nospaces") }, [], nil) - TEST(lambda { Nfs.UnescapeSpaces1("one\\040space") }, [], nil) + TEST(->() { Nfs.UnescapeSpaces1(nil) }, [], nil) + TEST(->() { Nfs.UnescapeSpaces1("") }, [], nil) + TEST(->() { Nfs.UnescapeSpaces1("\\040") }, [], nil) + TEST(->() { Nfs.UnescapeSpaces1("\\040\\040") }, [], nil) + TEST(->() { Nfs.UnescapeSpaces1("nospaces") }, [], nil) + TEST(->() { Nfs.UnescapeSpaces1("one\\040space") }, [], nil) TEST(lambda do Nfs.UnescapeSpaces1("\\040before,\\040two,\\040\\040after\\040") end, [], nil) DUMP("Nfs::UnescapeSpaces1 informative") - TEST(lambda { Nfs.UnescapeSpaces1("\\041\\") }, [], nil) + TEST(->() { Nfs.UnescapeSpaces1("\\041\\") }, [], nil) # see how it works when applied multiple times - TEST(lambda { Nfs.UnescapeSpaces1(Nfs.UnescapeSpaces1("\\040")) }, [], nil) + TEST(->() { Nfs.UnescapeSpaces1(Nfs.UnescapeSpaces1("\\040")) }, [], nil) nil end diff --git a/testsuite/tests/nfs-options.rb b/testsuite/tests/nfs-options.rb index eb5fa3c..0ef7b48 100644 --- a/testsuite/tests/nfs-options.rb +++ b/testsuite/tests/nfs-options.rb @@ -8,18 +8,18 @@ def main Yast.import "Assert" DUMP("NfsOptions::validate") - TEST(lambda { NfsOptions.validate("") }, [], nil) - TEST(lambda { NfsOptions.validate("defaults") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock,bg") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock,nobg") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock,rsize=8192") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock, bg") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock,unknownoption") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock,unknownassignment=true") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock,rsize=") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock,two=equal=signs") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock,retrans=trans=trans") }, [], nil) - TEST(lambda { NfsOptions.validate("nolock,intr=bogus") }, [], nil) + TEST(->() { NfsOptions.validate("") }, [], nil) + TEST(->() { NfsOptions.validate("defaults") }, [], nil) + TEST(->() { NfsOptions.validate("nolock,bg") }, [], nil) + TEST(->() { NfsOptions.validate("nolock,nobg") }, [], nil) + TEST(->() { NfsOptions.validate("nolock,rsize=8192") }, [], nil) + TEST(->() { NfsOptions.validate("nolock, bg") }, [], nil) + TEST(->() { NfsOptions.validate("nolock,unknownoption") }, [], nil) + TEST(->() { NfsOptions.validate("nolock,unknownassignment=true") }, [], nil) + TEST(->() { NfsOptions.validate("nolock,rsize=") }, [], nil) + TEST(->() { NfsOptions.validate("nolock,two=equal=signs") }, [], nil) + TEST(->() { NfsOptions.validate("nolock,retrans=trans=trans") }, [], nil) + TEST(->() { NfsOptions.validate("nolock,intr=bogus") }, [], nil) DUMP("NfsOptions::get_nfs41") Assert.Equal(false, NfsOptions.get_nfs41("")) diff --git a/testsuite/tests/r-check.rb b/testsuite/tests/r-check.rb index c0aad51..5402f3a 100644 --- a/testsuite/tests/r-check.rb +++ b/testsuite/tests/r-check.rb @@ -32,21 +32,21 @@ def main @IPv6_link_local_invalid = "[fe80::3%]" DUMP("CheckHostName") - TEST(lambda { CheckHostName(@OK_Name) }, [], nil) - TEST(lambda { CheckHostName(@TooLongName) }, [], nil) - TEST(lambda { CheckHostName(@IllegalName) }, [], nil) + TEST(->() { CheckHostName(@OK_Name) }, [], nil) + TEST(->() { CheckHostName(@TooLongName) }, [], nil) + TEST(->() { CheckHostName(@IllegalName) }, [], nil) # Too long & illegal char - TEST(lambda { CheckHostName(Ops.add(@TooLongName, "!")) }, [], nil) + TEST(->() { CheckHostName(Ops.add(@TooLongName, "!")) }, [], nil) # check IPv? adresses - TEST(lambda { CheckHostName(@IPv4) }, [], nil) - TEST(lambda { CheckHostName(@IPv4_invalid) }, [], nil) - TEST(lambda { CheckHostName(@IPv6) }, [], nil) - TEST(lambda { CheckHostName(@IPv6_invalid) }, [], nil) - TEST(lambda { CheckHostName(@IPv6_brackets) }, [], nil) - TEST(lambda { CheckHostName(@IPv6_brackets_invalid) }, [], nil) - TEST(lambda { CheckHostName(@IPv6_link_local_nb) }, [], nil) - TEST(lambda { CheckHostName(@IPv6_link_local_ib) }, [], nil) - TEST(lambda { CheckHostName(@IPv6_link_local_invalid) }, [], nil) + TEST(->() { CheckHostName(@IPv4) }, [], nil) + TEST(->() { CheckHostName(@IPv4_invalid) }, [], nil) + TEST(->() { CheckHostName(@IPv6) }, [], nil) + TEST(->() { CheckHostName(@IPv6_invalid) }, [], nil) + TEST(->() { CheckHostName(@IPv6_brackets) }, [], nil) + TEST(->() { CheckHostName(@IPv6_brackets_invalid) }, [], nil) + TEST(->() { CheckHostName(@IPv6_link_local_nb) }, [], nil) + TEST(->() { CheckHostName(@IPv6_link_local_ib) }, [], nil) + TEST(->() { CheckHostName(@IPv6_link_local_invalid) }, [], nil) DUMP("FormatHostnameForFstab") TEST(FormatHostnameForFstab("::1"), [], nil) diff --git a/testsuite/tests/r-fstab.rb b/testsuite/tests/r-fstab.rb index f9f3b59..8c4af66 100644 --- a/testsuite/tests/r-fstab.rb +++ b/testsuite/tests/r-fstab.rb @@ -49,27 +49,27 @@ def main ] DUMP("FstabTableItems") - TEST(lambda { FstabTableItems(@nfs_entries) }, [], nil) + TEST(->() { FstabTableItems(@nfs_entries) }, [], nil) DUMP("IsMpInFstab") # MountPoint in fstab - TEST(lambda { IsMpInFstab(@nfs_entries, "/home") }, [], nil) + TEST(->() { IsMpInFstab(@nfs_entries, "/home") }, [], nil) # MountPoint in fstab - TEST(lambda { IsMpInFstab(@nfs_entries, "/install") }, [], nil) + TEST(->() { IsMpInFstab(@nfs_entries, "/install") }, [], nil) # MountPoint NOT in fstab - TEST(lambda { IsMpInFstab(@nfs_entries, "/not/in/fstab") }, [], nil) + TEST(->() { IsMpInFstab(@nfs_entries, "/not/in/fstab") }, [], nil) DUMP("CheckPath") # Empty path - TEST(lambda { CheckPath("") }, [], nil) + TEST(->() { CheckPath("") }, [], nil) # Path is too long (cca 80 chars) - TEST(lambda { CheckPath(@PathTooLong) }, [], nil) + TEST(->() { CheckPath(@PathTooLong) }, [], nil) # First slash is missing - TEST(lambda { CheckPath("not/begins/with/slash") }, [], nil) + TEST(->() { CheckPath("not/begins/with/slash") }, [], nil) # Too long with slash - TEST(lambda { CheckPath(Ops.add("/", @PathTooLong)) }, [], nil) + TEST(->() { CheckPath(Ops.add("/", @PathTooLong)) }, [], nil) # Regular path - TEST(lambda { CheckPath("/regular/path") }, [], nil) + TEST(->() { CheckPath("/regular/path") }, [], nil) nil end diff --git a/testsuite/tests/r-spec.rb b/testsuite/tests/r-spec.rb index 88a1364..f3419fc 100644 --- a/testsuite/tests/r-spec.rb +++ b/testsuite/tests/r-spec.rb @@ -19,13 +19,13 @@ def main Yast.include self, "nfs/routines.rb" DUMP("SpecToServPath") - TEST(lambda { SpecToServPath("big.foo.com:/share/data") }, [], nil) - TEST(lambda { SpecToServPath("only.server.com:") }, [], nil) - TEST(lambda { SpecToServPath("nocolon.only.server.com") }, [], nil) - TEST(lambda { SpecToServPath(":/only/path") }, [], nil) - TEST(lambda { SpecToServPath("/nocolon/only/path") }, [], nil) - TEST(lambda { SpecToServPath("fe80::219:d1ff:feac:fd10:/path") }, [], nil) - TEST(lambda { SpecToServPath("") }, [], nil) + TEST(->() { SpecToServPath("big.foo.com:/share/data") }, [], nil) + TEST(->() { SpecToServPath("only.server.com:") }, [], nil) + TEST(->() { SpecToServPath("nocolon.only.server.com") }, [], nil) + TEST(->() { SpecToServPath(":/only/path") }, [], nil) + TEST(->() { SpecToServPath("/nocolon/only/path") }, [], nil) + TEST(->() { SpecToServPath("fe80::219:d1ff:feac:fd10:/path") }, [], nil) + TEST(->() { SpecToServPath("") }, [], nil) nil end diff --git a/testsuite/tests/r-strip.rb b/testsuite/tests/r-strip.rb index c27b612..928e3a1 100644 --- a/testsuite/tests/r-strip.rb +++ b/testsuite/tests/r-strip.rb @@ -19,10 +19,10 @@ def main Yast.include self, "nfs/routines.rb" DUMP("StripExtraSlash") - TEST(lambda { StripExtraSlash("") }, [], nil) - TEST(lambda { StripExtraSlash("/") }, [], nil) - TEST(lambda { StripExtraSlash("/normal/path") }, [], nil) - TEST(lambda { StripExtraSlash("/trailing/slash/") }, [], nil) + TEST(->() { StripExtraSlash("") }, [], nil) + TEST(->() { StripExtraSlash("/") }, [], nil) + TEST(->() { StripExtraSlash("/normal/path") }, [], nil) + TEST(->() { StripExtraSlash("/trailing/slash/") }, [], nil) nil end diff --git a/testsuite/tests/readwrite.rb b/testsuite/tests/readwrite.rb index 8d9225c..575fc97 100644 --- a/testsuite/tests/readwrite.rb +++ b/testsuite/tests/readwrite.rb @@ -118,11 +118,11 @@ def main } DUMP("Read") - TEST(lambda { Nfs.Read }, [@READ, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Read }, [@READ, @WRITE, @EXECUTE], nil) DUMP("Write OK") - TEST(lambda { Nfs.Write }, [@READ, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Write }, [@READ, @WRITE, @EXECUTE], nil) DUMP("Write KO") - TEST(lambda { Nfs.Write }, [@READ, @WRITE_KO, @EXECUTE], nil) + TEST(->() { Nfs.Write }, [@READ, @WRITE_KO, @EXECUTE], nil) nil end diff --git a/testsuite/tests/readwrite2.rb b/testsuite/tests/readwrite2.rb index 82106ba..2bb3919 100644 --- a/testsuite/tests/readwrite2.rb +++ b/testsuite/tests/readwrite2.rb @@ -148,31 +148,31 @@ def main # fstab contains nfs mounts & services are running DUMP("\nRead - nfs is in use & running\n") - TEST(lambda { Nfs.Read }, [@READ, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Read }, [@READ, @WRITE, @EXECUTE], nil) # fstab unchanged DUMP("\nWrite - nfs is in use - start services\n") - TEST(lambda { Nfs.Write }, [@READ, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Write }, [@READ, @WRITE, @EXECUTE], nil) # fstab contains nfs mounts & services are stopped:-( DUMP("\nRead - nfs is in use & stopped\n") - TEST(lambda { Nfs.Read }, [@READ3, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Read }, [@READ3, @WRITE, @EXECUTE], nil) # fstab unchanged - so, start services DUMP("\nWrite - nfs is in use - so, start services\n") - TEST(lambda { Nfs.Write }, [@READ3, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Write }, [@READ3, @WRITE, @EXECUTE], nil) # fstab contains no nfs mounts, services are running DUMP("\nRead - nfs not used & running\n") - TEST(lambda { Nfs.Read }, [@EMPTY, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Read }, [@EMPTY, @WRITE, @EXECUTE], nil) # fstab unchanged - so, STOP services DUMP("\nWrite - nfs not used - so, stopping services\n") - TEST(lambda { Nfs.Write }, [@EMPTY, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Write }, [@EMPTY, @WRITE, @EXECUTE], nil) # fstab contains no nfs mount, serives are stopped DUMP("\nRead - nfs not used & services are stopped\n") - TEST(lambda { Nfs.Read }, [@EMPTY3, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Read }, [@EMPTY3, @WRITE, @EXECUTE], nil) # fstab unchanged - so, leave services stopped DUMP("\nWrite - nfs not used; leave services stopped\n") - TEST(lambda { Nfs.Write }, [@EMPTY3, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Write }, [@EMPTY3, @WRITE, @EXECUTE], nil) # // nfs and portmap are running # DUMP ("\nRead - services are running\n"); From 7f71f3bba590ecdb348b250a12011a19156e1b17 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 14:06:18 +0100 Subject: [PATCH 05/40] rubocop: Style/MethodName: snake_case, exclude existing violations --- .rubocop.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ac96a3c..a19614f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -126,10 +126,15 @@ Style/LeadingCommentSpace: Style/LineEndConcatenation: Enabled: false -# Offense count: 61 -# Configuration parameters: EnforcedStyle, SupportedStyles. Style/MethodName: - Enabled: false + EnforcedStyle: snake_case + Exclude: + - src/clients/nfs-client4part.rb + - src/clients/nfs.rb + - src/include/nfs/routines.rb + - src/include/nfs/ui.rb + - src/include/nfs/wizards.rb + - src/modules/Nfs.rb # Offense count: 2 # Cop supports --auto-correct. From d20263bf176457ff3465de26192714ae37210c10 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 14:16:21 +0100 Subject: [PATCH 06/40] rubocop: Metrics/LineLength 135 -> 116 --- .rubocop.yml | 4 ++-- src/clients/nfs_auto.rb | 3 ++- src/include/nfs/ui.rb | 6 ++++-- src/modules/Nfs.rb | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a19614f..7f9beed 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,12 +45,12 @@ Metrics/CyclomaticComplexity: # Offense count: 56 # Configuration parameters: AllowURI, URISchemes. Metrics/LineLength: - Max: 135 + Max: 116 # Offense count: 46 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 222 + Max: 223 # Offense count: 13 Metrics/PerceivedComplexity: diff --git a/src/clients/nfs_auto.rb b/src/clients/nfs_auto.rb index be11307..b581723 100644 --- a/src/clients/nfs_auto.rb +++ b/src/clients/nfs_auto.rb @@ -54,7 +54,8 @@ def main if Ops.greater_than(Builtins.size(WFM.Args), 1) && Ops.is_list?(WFM.Args(1)) Builtins.y2warning( - "Old-style configuration detected (got list, expected map). section needs to be converted to match up-to-date schema" + "Old-style configuration detected (got list, expected map). " \ + " section needs to be converted to match up-to-date schema" ) end end diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index d49d50d..493d6b1 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -55,7 +55,8 @@ def initialize_nfs_ui(include_target) # Help, part 1 of 3 @help_text1 = _( - "

The table contains all directories \nexported from remote servers and mounted locally via NFS (NFS shares).

" + "

The table contains all directories \n" \ + "exported from remote servers and mounted locally via NFS (NFS shares).

" ) + # Help, part 2 of 3 _( @@ -454,7 +455,8 @@ def GetFstabEntry(fstab_ent, existing) helptext, _( "

\t\t\n" + - "For Mount Point, enter the path in the local file system where the directory should be mounted. With\n" + + "For Mount Point, enter the path in the local " \ + "file system where the directory should be mounted. With\n" + "Browse, select your mount point\n" + "interactively.

" ) diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index c739744..5c86842 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -567,7 +567,8 @@ def Summary # Mount NFS directory # @param [String] server remote server name # @param [String] share name of the exported directory - # @param [String] mpoint mount point (can be empty or nil, in this case it will be mounted in temporary directory) + # @param [String] mpoint mount point (can be empty or nil, + # in this case it will be mounted in a temporary directory) # @param [String] options mount options - e.g. "ro,hard,intr", see man nfs # @param [String] type nfs type (nfs vs. nfsv4) - if empty, 'nfs' is used # @return [String] directory where volume was mounted or nil if mount failed From 46063fb3a02e7440b687259731212b05f7dde9b9 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 14:27:00 +0100 Subject: [PATCH 07/40] rubocop: Style/VariableName: snake_case, except in old tests --- .rubocop.yml | 10 +++------- src/modules/NfsOptions.rb | 14 +++++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7f9beed..fd003b1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,10 +16,6 @@ Lint/LiteralInCondition: Lint/Loop: Enabled: false -# Offense count: 3 -Lint/UnderscorePrefixedVariableName: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. Lint/UnusedMethodArgument: @@ -189,10 +185,10 @@ Style/TrailingWhitespace: Style/TrivialAccessors: Enabled: false -# Offense count: 40 -# Configuration parameters: EnforcedStyle, SupportedStyles. Style/VariableName: - Enabled: false + EnforcedStyle: snake_case + Exclude: + - testsuite/tests/*.rb # Offense count: 16 # Cop supports --auto-correct. diff --git a/src/modules/NfsOptions.rb b/src/modules/NfsOptions.rb index b35a96b..d454dc1 100644 --- a/src/modules/NfsOptions.rb +++ b/src/modules/NfsOptions.rb @@ -175,8 +175,8 @@ def validate(options) def get_nfs41(options) option_list = from_string(options) - _ENABLED = "minorversion=1" - Builtins.contains(option_list, _ENABLED) + enabled = "minorversion=1" + Builtins.contains(option_list, enabled) end # Add or remove minorversion=1 according to nfs41. @@ -188,14 +188,14 @@ def set_nfs41(options, nfs41) # don't mutate the string unnecessarily return options if get_nfs41(options) == nfs41 - _ENABLED = "minorversion=1" - _DISABLED = "minorversion=0" + enabled = "minorversion=1" + disabled = "minorversion=0" option_list = from_string(options) - option_list = Builtins.filter(option_list) { |opt| opt != _ENABLED } - option_list = Builtins.filter(option_list) { |opt| opt != _DISABLED } + option_list = Builtins.filter(option_list) { |opt| opt != enabled } + option_list = Builtins.filter(option_list) { |opt| opt != disabled } - option_list = Builtins.add(option_list, _ENABLED) if nfs41 + option_list = Builtins.add(option_list, enabled) if nfs41 to_string(option_list) end From fae8099a420ee704f218b58208fd4521998c3e99 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 14:30:08 +0100 Subject: [PATCH 08/40] rubocop: Style/LineEndConcatenation --- .rubocop.yml | 5 ----- src/include/nfs/routines.rb | 14 +++++++------- src/include/nfs/ui.rb | 32 ++++++++++++++++---------------- src/modules/Nfs.rb | 4 ++-- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fd003b1..0ced51a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -117,11 +117,6 @@ Style/InfiniteLoop: Style/LeadingCommentSpace: Enabled: false -# Offense count: 27 -# Cop supports --auto-correct. -Style/LineEndConcatenation: - Enabled: false - Style/MethodName: EnforcedStyle: snake_case Exclude: diff --git a/src/include/nfs/routines.rb b/src/include/nfs/routines.rb index 694680d..fccfdf4 100644 --- a/src/include/nfs/routines.rb +++ b/src/include/nfs/routines.rb @@ -97,11 +97,11 @@ def CheckHostName(name) Report.Error( Builtins.sformat( _( - "The hostname entered is invalid. It must be\n" + - "shorter than 50 characters and only use\n" + - "valid IPv4, IPv6 or domain name.\n" + - "Valid IPv4: %1\n" + - "Valid IPv6: %2\n" + + "The hostname entered is invalid. It must be\n" \ + "shorter than 50 characters and only use\n" \ + "valid IPv4, IPv6 or domain name.\n" \ + "Valid IPv4: %1\n" \ + "Valid IPv6: %2\n" \ "Valid domain: %3" ), IP.Valid4, @@ -153,8 +153,8 @@ def CheckPath(name) Report.Error( Builtins.sformat( _( - "The path entered is invalid.\n" + - "It must be shorter than 70 characters\n" + + "The path entered is invalid.\n" \ + "It must be shorter than 70 characters\n" \ "and it must begin with a slash (/)." ) ) diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index 493d6b1..13b1750 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -60,24 +60,24 @@ def initialize_nfs_ui(include_target) ) + # Help, part 2 of 3 _( - "

Each NFS share is identified by remote NFS server address and\n" + - "exported directory, local directory where the remote directory is mounted, \n" + - "NFS type (either plain nfs or nfsv4) and mount options. For further information \n" + + "

Each NFS share is identified by remote NFS server address and\n" \ + "exported directory, local directory where the remote directory is mounted, \n" \ + "NFS type (either plain nfs or nfsv4) and mount options. For further information \n" \ "about mounting NFS and mount options, refer to man nfs.

" ) + # Help, part 3 of 3 _( - "

To mount a new NFS share, click Add. To change the configuration of\n" + - "a currently mounted share, click Edit. Remove and unmount a selected\n" + + "

To mount a new NFS share, click Add. To change the configuration of\n" \ + "a currently mounted share, click Edit. Remove and unmount a selected\n" \ "share with Delete.

\n" ) @help_text2 = Ops.add( _( - "

If you need to access NFSv4 shares (NFSv4 is a newer version of the NFS\n" + - "protocol), check the Enable NFSv4 option. In that case, you might need\n" + - "to supply specific a NFSv4 Domain Name required for the correct setting\n" + + "

If you need to access NFSv4 shares (NFSv4 is a newer version of the NFS\n" \ + "protocol), check the Enable NFSv4 option. In that case, you might need\n" \ + "to supply specific a NFSv4 Domain Name required for the correct setting\n" \ "of file/directory access rights.

\n" ), Ops.get_string(@fw_cwm_widget, "help", "") @@ -346,8 +346,8 @@ def GetFstabEntry(fstab_ent, existing) error_msg = Ops.add( error_msg, _( - "\n" + - "This could be caused by a running SuSEfirewall2,\n" + + "\n" \ + "This could be caused by a running SuSEfirewall2,\n" \ "which probably blocks the network scanning." ) ) @@ -435,8 +435,8 @@ def GetFstabEntry(fstab_ent, existing) #help text 1/4 # change: locally defined -> servers on LAN helptext = _( - "

Enter the NFS Server Hostname. With\n" + - "Choose, browse through a list of\n" + + "

Enter the NFS Server Hostname. With\n" \ + "Choose, browse through a list of\n" \ "NFS servers on the local network.

\n" ) # help text 2/4 @@ -444,9 +444,9 @@ def GetFstabEntry(fstab_ent, existing) helptext = Ops.add( helptext, _( - "

In Remote File System,\n" + - "enter the path to the directory on the NFS server. Use\n" + - "Select to select one from those exported by the server.\n" + + "

In Remote File System,\n" \ + "enter the path to the directory on the NFS server. Use\n" \ + "Select to select one from those exported by the server.\n" \ "

" ) ) @@ -457,7 +457,7 @@ def GetFstabEntry(fstab_ent, existing) "

\t\t\n" + "For Mount Point, enter the path in the local " \ "file system where the directory should be mounted. With\n" + - "Browse, select your mount point\n" + + "Browse, select your mount point\n" \ "interactively.

" ) ) diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index 5c86842..0d2f5e0 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -447,8 +447,8 @@ def WriteOnly # error popup message Report.Error( _( - "Unable to write to /etc/fstab.\n" + - "No changes will be made to the\n" + + "Unable to write to /etc/fstab.\n" \ + "No changes will be made to the\n" \ "the NFS client configuration.\n" ) ) From 2793dc01e2d6900caec159d9cdf331b155561b8d Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 14:54:42 +0100 Subject: [PATCH 09/40] rubocop: Style/Documentation, except old tests --- .rubocop.yml | 4 ++-- src/clients/nfs-client.rb | 5 ++--- src/clients/nfs-client4part.rb | 6 ++---- src/clients/nfs.rb | 13 ++----------- src/clients/nfs_auto.rb | 24 ++---------------------- src/include/nfs/routines.rb | 19 ++----------------- src/include/nfs/ui.rb | 20 ++------------------ src/include/nfs/wizards.rb | 8 ++------ src/modules/Nfs.rb | 17 ++--------------- src/modules/NfsOptions.rb | 2 ++ 10 files changed, 20 insertions(+), 98 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0ced51a..0de46a4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -73,9 +73,9 @@ Style/BracesAroundHashParameters: Style/CommentAnnotation: Enabled: false -# Offense count: 20 Style/Documentation: - Enabled: false + Exclude: + - testsuite/tests/*.rb # Offense count: 9 # Cop supports --auto-correct. diff --git a/src/clients/nfs-client.rb b/src/clients/nfs-client.rb index 56ab273..cecd6b4 100644 --- a/src/clients/nfs-client.rb +++ b/src/clients/nfs-client.rb @@ -1,9 +1,8 @@ # encoding: utf-8 -# Author: Martin Vidner -# Summary: Just a redirection -# $Id$ +# YaST namespace module Yast + # Just a redirection class NfsClientClient < Client def main @target = "nfs" diff --git a/src/clients/nfs-client4part.rb b/src/clients/nfs-client4part.rb index c23b935..9ce713b 100644 --- a/src/clients/nfs-client4part.rb +++ b/src/clients/nfs-client4part.rb @@ -1,10 +1,8 @@ # encoding: utf-8 -# File: clients/ -# Summary: nfs-client stuff made accesible from -# Author: Bubli -# +# YaST namespace module Yast + # nfs-client stuff made accesible from the partitioner class NfsClient4partClient < Client def main Yast.import "UI" diff --git a/src/clients/nfs.rb b/src/clients/nfs.rb index 9636ae3..b30620b 100644 --- a/src/clients/nfs.rb +++ b/src/clients/nfs.rb @@ -1,17 +1,8 @@ # encoding: utf-8 -# File: clients/nfs.ycp -# Package: Configuration of NFS -# Summary: Main file -# Authors: -# Jan Holesovsky -# Dan Vesely -# Martin Vidner -# -# $Id$ -# -# Main file for nfs configuration. Uses all other files. +# YaST namespace module Yast + # Main file class NfsClient < Client def main Yast.import "UI" diff --git a/src/clients/nfs_auto.rb b/src/clients/nfs_auto.rb index b581723..f029488 100644 --- a/src/clients/nfs_auto.rb +++ b/src/clients/nfs_auto.rb @@ -1,28 +1,8 @@ # encoding: utf-8 -# File: -# nfs_auto.ycp -# -# Package: -# Configuration of NFS client -# -# Summary: -# Client for autoinstallation -# -# Authors: -# Martin Vidner -# -# $Id$ -# -# This is a client for autoinstallation. It takes its arguments, -# goes through the configuration and return the setting. -# Does not do any changes to the configuration. - -# @param first a map of mail settings -# @return [Hash] edited settings or empty map if canceled -# @example map mm = $[ "FAIL_DELAY" : "77" ]; -# @example map ret = WFM::CallModule ("mail_auto", [ mm ]); +# YaST namespace module Yast + # Client for autoinstallation class NfsAutoClient < Client def main Yast.import "UI" diff --git a/src/include/nfs/routines.rb b/src/include/nfs/routines.rb index fccfdf4..180b263 100644 --- a/src/include/nfs/routines.rb +++ b/src/include/nfs/routines.rb @@ -1,23 +1,8 @@ # encoding: utf-8 -# File: -# routines.ycp -# -# Module: -# Configuration of nfs -# -# Summary: -# Network NFS routines -# -# Authors: -# Jan Holesovsky -# Dan Vesely -# -# $Id$ -# -# Network NFS routines -# +# YaST namespace module Yast + # Miscellaneous module NfsRoutinesInclude def initialize_nfs_routines(include_target) textdomain "nfs" diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index 13b1750..d3ce09a 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -1,24 +1,8 @@ # encoding: utf-8 -# File: -# ui.ycp -# -# Module: -# Configuration of nfs -# -# Summary: -# Network NFS client dialogs -# -# Authors: -# Jan Holesovsky -# Dan Vesely -# Martin Vidner -# -# $Id$ -# -# Network NFS client dialogs -# +# YaST namespace module Yast + # NFS client dialogs module NfsUiInclude def initialize_nfs_ui(include_target) Yast.import "UI" diff --git a/src/include/nfs/wizards.rb b/src/include/nfs/wizards.rb index ae360c2..b0b0b18 100644 --- a/src/include/nfs/wizards.rb +++ b/src/include/nfs/wizards.rb @@ -1,12 +1,8 @@ # encoding: utf-8 -# File: include/nfs/wizards.ycp -# Package: Configuration of nfs -# Summary: Wizards definitions -# Authors: Martin Vidner -# -# $Id$ +# YaST namespace module Yast + # Wizards definitions module NfsWizardsInclude def initialize_nfs_wizards(include_target) Yast.import "UI" diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index 0d2f5e0..6b00069 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -1,23 +1,10 @@ # encoding: utf-8 -# File: -# Nfs.ycp -# -# Module: -# Configuration of nfs -# -# Summary: -# NFS client configuration data, I/O functions. -# -# Authors: -# Jan Holesovsky -# Dan Vesely -# Martin Vidner -# -# $Id$ require "yast" +# YaST namespace module Yast + # NFS client configuration data, I/O functions. class NfsClass < Module def main diff --git a/src/modules/NfsOptions.rb b/src/modules/NfsOptions.rb index d454dc1..e1ad6f2 100644 --- a/src/modules/NfsOptions.rb +++ b/src/modules/NfsOptions.rb @@ -2,7 +2,9 @@ require "yast" +# YaST namespace module Yast + # Handle NFS mount options class NfsOptionsClass < Module # The options should be kept synced with the code that handles them, # which is not an easy task, as there are many places: From 6d011883e33bc04056caeb667b32723287b8ce2f Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 14:59:36 +0100 Subject: [PATCH 10/40] rubocop: Style/LeadingCommentSpace --- .rubocop.yml | 5 ----- Rakefile | 2 +- src/clients/nfs.rb | 4 ---- src/include/nfs/ui.rb | 9 +++------ src/modules/Nfs.rb | 24 ++++++++++++------------ 5 files changed, 16 insertions(+), 28 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0de46a4..ea3bc13 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -112,11 +112,6 @@ Style/IndentationWidth: Style/InfiniteLoop: Enabled: false -# Offense count: 20 -# Cop supports --auto-correct. -Style/LeadingCommentSpace: - Enabled: false - Style/MethodName: EnforcedStyle: snake_case Exclude: diff --git a/Rakefile b/Rakefile index 927a322..2432dd5 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ require "yast/rake" Yast::Tasks.configuration do |conf| - #lets ignore license check for now + # lets ignore license check for now conf.skip_license_check << /.*/ end diff --git a/src/clients/nfs.rb b/src/clients/nfs.rb index b30620b..e9f3e04 100644 --- a/src/clients/nfs.rb +++ b/src/clients/nfs.rb @@ -7,12 +7,8 @@ class NfsClient < Client def main Yast.import "UI" - #** - #

Configuration of NFS

- textdomain "nfs" - # The main () Builtins.y2milestone("----------------------------------------") Builtins.y2milestone("NFS module started") diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index d3ce09a..88b460c 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -322,11 +322,11 @@ def GetFstabEntry(fstab_ent, existing) UI.CloseDialog end if @hosts == [] || @hosts == nil - #Translators: 1st part of error message + # Translators: 1st part of error message error_msg = _("No NFS server has been found on your network.") if SuSEFirewall.GetStartService - #Translators: 2nd part of error message (1st one is 'No nfs servers have been found ...) + # Translators: 2nd part of error message (1st one is 'No nfs servers have been found ...) error_msg = Ops.add( error_msg, _( @@ -416,7 +416,7 @@ def GetFstabEntry(fstab_ent, existing) ret = :ok end elsif ret == :help - #help text 1/4 + # help text 1/4 # change: locally defined -> servers on LAN helptext = _( "

Enter the NFS Server Hostname. With\n" \ @@ -503,7 +503,6 @@ def FstabTab def SettingsTab settings_content = VBox( - #`VSpacing (1), HBox( Left(CheckBox(Id(:enable_nfs4), Opt(:notify), _("Enable NFSv4"))), Left(InputField(Id(:nfs4_domain), _("NFSv4 Domain Name"))), @@ -684,8 +683,6 @@ def FstabDialog false, true ) - #Wizard::HideBackButton(); - #Wizard::SetAbortButton(`abort, Label::CancelButton()); InitFstabEntries() diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index 6b00069..5c2dd05 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -157,10 +157,10 @@ def GetOptionsAndEntries(any_settings, global_options, entries) def FillEntriesDefaults(entries) entries = deep_copy(entries) Builtins.maplist(entries) do |e| - #Backwards compatibility: with FaTE#302031, we support nfsv4 mounts - #thus we need to keep info on nfs version (v3 vs. v4) - #But older AY profiles might not contain this element - #so let's assume nfsv3 in that case (#395850) + # Backwards compatibility: with FaTE#302031, we support nfsv4 mounts + # thus we need to keep info on nfs version (v3 vs. v4) + # But older AY profiles might not contain this element + # so let's assume nfsv3 in that case (#395850) Ops.set(e, "vfstype", "nfs") if !Builtins.haskey(e, "vfstype") deep_copy(e) end @@ -315,8 +315,8 @@ def UnescapeSpaces(entries) end def FindPortmapper - #testsuite is dumb - it can't distinguish between the existence - #of two services - either both exists or both do not + # testsuite is dumb - it can't distinguish between the existence + # of two services - either both exists or both do not return "portmap" if Mode.testsuite Service.Find(["rpcbind", "portmap"]) end @@ -326,7 +326,7 @@ def FindPortmapper # Reads NFS settings from the SCR (.etc.fstab) # @return true on success def Read - #Read /etc/fstab if we're running standalone (otherwise, libstorage does the job) + # Read /etc/fstab if we're running standalone (otherwise, libstorage does the job) if !@skip_fstab fstab = Convert.convert( SCR.Read(path(".etc.fstab")), @@ -356,9 +356,9 @@ def Read Progress.set(progress_orig) @portmapper = FindPortmapper() - #There is neither rpcbind nor portmap + # There is neither rpcbind nor portmap if @portmapper == "" - #so let's install rpcbind (default since #423026) + # so let's install rpcbind (default since #423026) @required_packages = Builtins.add(@required_packages, "rpcbind") @portmapper = "rpcbind" end @@ -405,7 +405,7 @@ def WriteOnly Convert.convert( Builtins.union( entry, - { "freq" => 0, "passno" => 0 } #"vfstype": "nfs", + { "freq" => 0, "passno" => 0 } # "vfstype": "nfs", ), :from => "map", :to => "map " @@ -690,11 +690,11 @@ def AutoPackages # Uses RPC broadcast to mountd. # @return a list of hostnames def ProbeServers - #newer, shinier, better rpcinfo from rpcbind (#450056) + # newer, shinier, better rpcinfo from rpcbind (#450056) prog_name = "/sbin/rpcinfo" delim = "" - #fallback from glibc (uses different field separators, grr :( ) + # fallback from glibc (uses different field separators, grr :( ) if !FileUtils.Exists(prog_name) prog_name = "/usr/sbin/rpcinfo" delim = "-d ' ' " From b5820edc008821e486a29891ed282b101061b3ec Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 15:12:09 +0100 Subject: [PATCH 11/40] rubocop: Style/WordArray is disabled per SUSE style --- .rubocop.yml | 5 ----- .rubocop_yast_style.yml | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ea3bc13..5125a49 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -179,8 +179,3 @@ Style/VariableName: EnforcedStyle: snake_case Exclude: - testsuite/tests/*.rb - -# Offense count: 16 -# Cop supports --auto-correct. -Style/WordArray: - MinSize: 29 diff --git a/.rubocop_yast_style.yml b/.rubocop_yast_style.yml index 62524eb..0cdfdab 100644 --- a/.rubocop_yast_style.yml +++ b/.rubocop_yast_style.yml @@ -11,3 +11,6 @@ Style/StringLiterals: Style/HashSyntax: EnforcedStyle: hash_rockets +# https://github.com/SUSE/style-guides/blob/master/Ruby.md#arrays +Style/WordArray: + Enabled: false From dbe113c1b484001875eb41e8d3ad051cb931380b Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 15:13:16 +0100 Subject: [PATCH 12/40] rubocop: Lint/UselessAssignment removed dead code this way :-) --- .rubocop.yml | 4 ---- src/clients/nfs.rb | 1 - src/include/nfs/ui.rb | 7 ------- src/modules/Nfs.rb | 1 - 4 files changed, 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5125a49..2a90310 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,10 +21,6 @@ Lint/Loop: Lint/UnusedMethodArgument: Enabled: false -# Offense count: 9 -Lint/UselessAssignment: - Enabled: false - # Offense count: 4 Metrics/BlockNesting: Max: 4 diff --git a/src/clients/nfs.rb b/src/clients/nfs.rb index e9f3e04..a28748a 100644 --- a/src/clients/nfs.rb +++ b/src/clients/nfs.rb @@ -135,7 +135,6 @@ def main # @param [Hash] options command options # @return false so that Write is not called in non-interactive mode def NfsListHandler(options) - options = deep_copy(options) nfs_entries = deep_copy(Nfs.nfs_entries) if Ops.less_than(Builtins.size(nfs_entries), 1) CommandLine.Print(Summary.NotConfigured) diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index 88b460c..d075137 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -71,7 +71,6 @@ def initialize_nfs_ui(include_target) # Read settings dialog # @return `abort if aborted and `next otherwise def ReadDialog - ret = nil ret = Nfs.Read ret ? :next : :abort end @@ -102,7 +101,6 @@ def ChooseItem(title, items) ) ) UI.SetFocus(Id(:items)) - ret = nil begin ret = UI.UserInput end while ret != :cancel && ret != :ok @@ -310,7 +308,6 @@ def GetFstabEntry(fstab_ent, existing) UI.ChangeWidget(Id(:serverent), :Value, server) UI.SetFocus(Id(:serverent)) - ret = nil begin ret = UI.UserInput @@ -609,7 +606,6 @@ def HandleEvent(widget) UI.ChangeWidget(Id(:fstable), :Items, FstabTableItems(@nfs_entries)) elsif widget == :editbut - count = 0 entry = GetFstabEntry( Ops.get(@nfs_entries, entryno, {}), Convert.convert( @@ -691,9 +687,6 @@ def FstabDialog # so it is OK to always set focus to the table UI.SetFocus(Id(:fstable)) - event = nil - ret = nil - entryno = -1 begin event = UI.WaitForEvent ret = Ops.get(event, "ID") diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index 5c2dd05..2621b1f 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -276,7 +276,6 @@ def EscapeSpaces(entries) # @param [String] s where to replace # @return the changed string def gsub(regex, replacement, s) - temp = nil while true # argh, regexpsub logs an error if it cannot sub break if !Builtins.regexpmatch(s, Ops.add(Ops.add(".*", regex), ".*")) From 2abfe373da35a8738da50771ebf73b3dfc6f4a6e Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 15:44:15 +0100 Subject: [PATCH 13/40] rubocop: Lint/Loop Conflicts: .rubocop.yml --- .rubocop.yml | 8 ++------ src/include/nfs/ui.rb | 15 +++++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2a90310..950acc2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,10 +12,6 @@ inherit_from: Lint/LiteralInCondition: Enabled: false -# Offense count: 3 -Lint/Loop: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. Lint/UnusedMethodArgument: @@ -32,7 +28,7 @@ Metrics/ClassLength: # Offense count: 13 Metrics/CyclomaticComplexity: - Max: 30 + Max: 31 # Offense count: 56 # Configuration parameters: AllowURI, URISchemes. @@ -46,7 +42,7 @@ Metrics/MethodLength: # Offense count: 13 Metrics/PerceivedComplexity: - Max: 34 + Max: 35 # Offense count: 2 # Cop supports --auto-correct. diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index d075137..b057cba 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -101,9 +101,10 @@ def ChooseItem(title, items) ) ) UI.SetFocus(Id(:items)) - begin + loop do ret = UI.UserInput - end while ret != :cancel && ret != :ok + break if ret == :ok || ret == :cancel + end if ret == :ok item = Convert.to_string(UI.QueryWidget(Id(:items), :CurrentItem)) @@ -308,7 +309,7 @@ def GetFstabEntry(fstab_ent, existing) UI.ChangeWidget(Id(:serverent), :Value, server) UI.SetFocus(Id(:serverent)) - begin + loop do ret = UI.UserInput if ret == :choose @@ -452,7 +453,8 @@ def GetFstabEntry(fstab_ent, existing) # popup heading Popup.LongText(_("Help"), RichText(helptext), 50, 18) end - end while ret != :ok && ret != :cancel + break if ret == :ok || ret == :cancel + end UI.CloseDialog Wizard.RestoreScreenShotName @@ -687,7 +689,7 @@ def FstabDialog # so it is OK to always set focus to the table UI.SetFocus(Id(:fstable)) - begin + loop do event = UI.WaitForEvent ret = Ops.get(event, "ID") if ret == :ok @@ -699,7 +701,8 @@ def FstabDialog else HandleEvent(ret) end - end while ret != :back && ret != :next && ret != :abort + break if [:back, :next, :abort].include? ret + end if ret == :next # grab current settings, store them to SuSEFirewall:: From 097355dcaa7e405d096f8a743a50b0331109379a Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 15:53:13 +0100 Subject: [PATCH 14/40] rubocop: Lint/LiteralInCondition bwahahahaha!! --- .rubocop.yml | 4 ---- src/modules/Nfs.rb | 25 ++----------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 950acc2..a41b6b7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -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: diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index 2621b1f..1b46c5d 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -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 From 342679e34be10b82bdb1f6390c35dd3b2b4f2308 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 15:56:48 +0100 Subject: [PATCH 15/40] rubocop: Lint/UnusedMethodArgument --- .rubocop.yml | 5 ----- src/clients/nfs.rb | 2 +- src/include/nfs/routines.rb | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a41b6b7..d5758c0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,11 +8,6 @@ inherit_from: .rubocop_yast_style.yml -# Offense count: 1 -# Cop supports --auto-correct. -Lint/UnusedMethodArgument: - Enabled: false - # Offense count: 4 Metrics/BlockNesting: Max: 4 diff --git a/src/clients/nfs.rb b/src/clients/nfs.rb index a28748a..54a6219 100644 --- a/src/clients/nfs.rb +++ b/src/clients/nfs.rb @@ -134,7 +134,7 @@ def main # Print summary in command line # @param [Hash] options command options # @return false so that Write is not called in non-interactive mode - def NfsListHandler(options) + def NfsListHandler(_options) nfs_entries = deep_copy(Nfs.nfs_entries) if Ops.less_than(Builtins.size(nfs_entries), 1) CommandLine.Print(Summary.NotConfigured) diff --git a/src/include/nfs/routines.rb b/src/include/nfs/routines.rb index 180b263..181d9e0 100644 --- a/src/include/nfs/routines.rb +++ b/src/include/nfs/routines.rb @@ -4,7 +4,7 @@ module Yast # Miscellaneous module NfsRoutinesInclude - def initialize_nfs_routines(include_target) + def initialize_nfs_routines(_include_target) textdomain "nfs" Yast.import "Package" From b16c5e149b19903569990369b37a2df9753cc3c0 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:04:36 +0100 Subject: [PATCH 16/40] rubocop: Style/BlockEndNewline: --- .rubocop.yml | 10 ---------- src/modules/Nfs.rb | 32 ++++++++++++++++++-------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d5758c0..67c6194 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -35,16 +35,6 @@ Metrics/MethodLength: Metrics/PerceivedComplexity: Max: 35 -# Offense count: 2 -# Cop supports --auto-correct. -Style/BlockEndNewline: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -Style/Blocks: - Enabled: false - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index 1b46c5d..ff04a57 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -260,13 +260,15 @@ def EscapeSpaces1(s) # @return escaped entries def EscapeSpaces(entries) entries = deep_copy(entries) - Builtins.maplist(entries) { |entry| Builtins.mapmap(entry) do |key, value| - { - key => Ops.is_string?(value) ? - EscapeSpaces1(Convert.to_string(value)) : - value - } - end } + Builtins.maplist(entries) do |entry| + Builtins.mapmap(entry) do |key, value| + { + key => Ops.is_string?(value) ? + EscapeSpaces1(Convert.to_string(value)) : + value + } + end + end end # Un-escape spaces "\\040" -> " " @@ -283,13 +285,15 @@ def UnescapeSpaces1(s) # @return escaped entries def UnescapeSpaces(entries) entries = deep_copy(entries) - Builtins.maplist(entries) { |entry| Builtins.mapmap(entry) do |key, value| - { - key => Ops.is_string?(value) ? - UnescapeSpaces1(Convert.to_string(value)) : - value - } - end } + Builtins.maplist(entries) do |entry| + Builtins.mapmap(entry) do |key, value| + { + key => Ops.is_string?(value) ? + UnescapeSpaces1(Convert.to_string(value)) : + value + } + end + end end def FindPortmapper From 9f9f76a7efc83aa45b94b085796c27647b862610 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:09:57 +0100 Subject: [PATCH 17/40] rubocop: Style/BracesAroundHashParameters --- .rubocop.yml | 6 ------ src/include/nfs/ui.rb | 4 ++-- src/modules/Nfs.rb | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 67c6194..f0dd0d8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -35,12 +35,6 @@ Metrics/MethodLength: Metrics/PerceivedComplexity: Max: 35 -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/BracesAroundHashParameters: - Enabled: false - # Offense count: 3 # Configuration parameters: Keywords. Style/CommentAnnotation: diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index b057cba..d494f2f 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -581,7 +581,7 @@ def HandleEvent(widget) CWMFirewallInterfaces.OpenFirewallHandle( @fw_cwm_widget, "", - { "ID" => widget } + "ID" => widget ) end if UI.WidgetExists(Id(:fstable)) @@ -657,7 +657,7 @@ def HandleEvent(widget) InitSettings() Wizard.SetHelpText(@help_text2) elsif widget == :overview - SaveSettings({ "ID" => widget }) + SaveSettings("ID" => widget) UI.ReplaceWidget(Id(:rp), FstabTab()) InitFstabEntries() Wizard.SetHelpText(@help_text1) diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index ff04a57..b219a4f 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -387,7 +387,7 @@ def WriteOnly Convert.convert( Builtins.union( entry, - { "freq" => 0, "passno" => 0 } # "vfstype": "nfs", + "freq" => 0, "passno" => 0 # "vfstype": "nfs", ), :from => "map", :to => "map " @@ -408,7 +408,7 @@ def WriteOnly SCR.Execute( path(".target.bash"), "/bin/cp $ORIG $BACKUP", - { "ORIG" => "/etc/fstab", "BACKUP" => "/etc/fstab.YaST2.save" } + "ORIG" => "/etc/fstab", "BACKUP" => "/etc/fstab.YaST2.save" ) fstab = EscapeSpaces(fstab) From 30e0dc29cef77b651ba7a6d6f1bb5109f43ab9b3 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:12:13 +0100 Subject: [PATCH 18/40] rubocop: Style/CommentAnnotation --- .rubocop.yml | 5 ----- src/clients/nfs.rb | 4 ++-- src/modules/NfsOptions.rb | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f0dd0d8..bd0c8e1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -35,11 +35,6 @@ Metrics/MethodLength: Metrics/PerceivedComplexity: Max: 35 -# Offense count: 3 -# Configuration parameters: Keywords. -Style/CommentAnnotation: - Enabled: false - Style/Documentation: Exclude: - testsuite/tests/*.rb diff --git a/src/clients/nfs.rb b/src/clients/nfs.rb index 54a6219..84c3970 100644 --- a/src/clients/nfs.rb +++ b/src/clients/nfs.rb @@ -34,7 +34,7 @@ def main "finish" => fun_ref(Nfs.method(:Write), "boolean ()"), "actions" => { "list" => { - # TODO summary is probably better... + # TODO: summary is probably better... "handler" => fun_ref( method(:NfsListHandler), "boolean (map)" @@ -61,7 +61,7 @@ def main } }, "options" => { - # TODO adjust names? create comaptibility aliases? + # TODO: adjust names? create comaptibility aliases? "spec" => { "type" => "string", # host:path diff --git a/src/modules/NfsOptions.rb b/src/modules/NfsOptions.rb index e1ad6f2..301efcf 100644 --- a/src/modules/NfsOptions.rb +++ b/src/modules/NfsOptions.rb @@ -182,7 +182,7 @@ def get_nfs41(options) end # Add or remove minorversion=1 according to nfs41. - # FIXME vfstype=nfs4 is deprecated in favor of nfsvers=4 (aka vers=4) + # FIXME: vfstype=nfs4 is deprecated in favor of nfsvers=4 (aka vers=4) # @param [String] options fstab option string # @param [Boolean] nfs41 is version >= 4.1 enabled # @return new fstab option string From 609425e9c2742d30732ddac40ef33e594ba7f802 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:13:31 +0100 Subject: [PATCH 19/40] rubocop: Style/EmptyLines Style/EmptyLinesAroundBody --- .rubocop.yml | 10 ---------- src/include/nfs/routines.rb | 2 -- src/include/nfs/ui.rb | 1 - src/modules/Nfs.rb | 6 ------ testsuite/tests/escape.rb | 1 - 5 files changed, 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index bd0c8e1..319c556 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -39,16 +39,6 @@ Style/Documentation: Exclude: - testsuite/tests/*.rb -# Offense count: 9 -# Cop supports --auto-correct. -Style/EmptyLines: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Style/EmptyLinesAroundBody: - Enabled: false - # Offense count: 9 # Configuration parameters: Exclude. Style/FileName: diff --git a/src/include/nfs/routines.rb b/src/include/nfs/routines.rb index 181d9e0..daa627f 100644 --- a/src/include/nfs/routines.rb +++ b/src/include/nfs/routines.rb @@ -40,7 +40,6 @@ def SpecToServPath(spec) term(:couple, serv, spec) end - # Creates a list of ui table items for nfs fstab entries # @param [Array] fstab list of nfs fstab entries # @return itemized table entries @@ -147,7 +146,6 @@ def CheckPath(name) false end - # Strips a superfluous slash off the end of a pathname. # @param [String] p pathname # @return stripped pathname diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index d494f2f..97cbbd6 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -56,7 +56,6 @@ def initialize_nfs_ui(include_target) "share with Delete.

\n" ) - @help_text2 = Ops.add( _( "

If you need to access NFSv4 shares (NFSv4 is a newer version of the NFS\n" \ diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index b219a4f..ce89cd4 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -7,7 +7,6 @@ module Yast # NFS client configuration data, I/O functions. class NfsClass < Module def main - textdomain "nfs" Yast.import "FileUtils" @@ -25,7 +24,6 @@ def main Yast.include self, "nfs/routines.rb" - # default value of settings modified @modified = false @@ -109,7 +107,6 @@ def GetOptionsAndEntriesSLE11(settings, global_options, entries) nil end - def GetOptionsAndEntriesMap(settings, global_options, entries) settings = deep_copy(settings) global_options.value = Builtins.remove(settings, "nfs_entries") @@ -532,7 +529,6 @@ def Summary summary end - # Mount NFS directory # @param [String] server remote server name # @param [String] share name of the exported directory @@ -582,7 +578,6 @@ def Mount(server, share, mpoint, options, type) return nil end - # start portmapper if it isn't running unless Service.active?(portmapper) unless Service.Start(portmapper) @@ -638,7 +633,6 @@ def Unmount(mpoint) found = true if (type == "nfs" || type == "nfs4") && file == mpoint end - if found command = Builtins.sformat("/bin/umount %1", mpoint) diff --git a/testsuite/tests/escape.rb b/testsuite/tests/escape.rb index 04f2d6e..3a0a794 100644 --- a/testsuite/tests/escape.rb +++ b/testsuite/tests/escape.rb @@ -40,7 +40,6 @@ def main # see how it works when applied multiple times TEST(->() { Nfs.EscapeSpaces1(Nfs.EscapeSpaces1(" ")) }, [], nil) - DUMP("Nfs::UnescapeSpaces1 normative") TEST(->() { Nfs.UnescapeSpaces1(nil) }, [], nil) TEST(->() { Nfs.UnescapeSpaces1("") }, [], nil) From f74432a08be6140b0aa75e7417e49562c3f51842 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:16:45 +0100 Subject: [PATCH 20/40] rubocop: Style/IfUnlessModifier --- .rubocop.yml | 5 ----- src/modules/NfsOptions.rb | 6 ++---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 319c556..689ac0d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -44,11 +44,6 @@ Style/Documentation: Style/FileName: Enabled: false -# Offense count: 1 -# Configuration parameters: MaxLineLength. -Style/IfUnlessModifier: - Enabled: false - # Offense count: 10 # Cop supports --auto-correct. Style/IndentationConsistency: diff --git a/src/modules/NfsOptions.rb b/src/modules/NfsOptions.rb index 301efcf..aa4c7f6 100644 --- a/src/modules/NfsOptions.rb +++ b/src/modules/NfsOptions.rb @@ -134,12 +134,10 @@ def non_value_option?(option) # Checks the nfs options for /etc/fstab: # nonempty, comma separated list of foo,nofoo,bar=baz (see nfs(5)) # @param [String] options options - # @return a translated string with error message, emtpy string if ok + # @return a translated string with error message, emtpy string if ok def validate(options) # To translators: error popup - if options.empty? - return _("Empty option strings are not allowed.") - end + return _("Empty option strings are not allowed.") if options.empty? error_message = "" From ff2e9fc7db3ac053f2fdc470b2f2eef543aa07ae Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:19:37 +0100 Subject: [PATCH 21/40] rubocop: Style/IndentationConsistency Style/IndentationWidth --- .rubocop.yml | 10 -- src/modules/NfsOptions.rb | 194 +++++++++++++++++++------------------- 2 files changed, 97 insertions(+), 107 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 689ac0d..eca3467 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -44,16 +44,6 @@ Style/Documentation: Style/FileName: Enabled: false -# Offense count: 10 -# Cop supports --auto-correct. -Style/IndentationConsistency: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Style/IndentationWidth: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. Style/InfiniteLoop: diff --git a/src/modules/NfsOptions.rb b/src/modules/NfsOptions.rb index aa4c7f6..23d378a 100644 --- a/src/modules/NfsOptions.rb +++ b/src/modules/NfsOptions.rb @@ -6,103 +6,103 @@ module Yast # Handle NFS mount options class NfsOptionsClass < Module - # The options should be kept synced with the code that handles them, - # which is not an easy task, as there are many places: - # - util-linux.rpm - # man 8 mount - # https://git.kernel.org/?p=utils/util-linux/util-linux.git;a=history;f=libmount/src/optmap.c - # - nfs-client.rpm (nfs-utils.src.rpm) - # man 5 nfs - # http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=history;f=utils/mount/nfsmount.c - # - kernel: fs/nfs/super.c - # http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=history;f=fs/nfs/super.c - # Note that minorversion in particular is mentioned only in the kernel - # but not in nfs-utils. - - # these can be negated by "no" - NEGATABLE_OPTIONS = [ - "ac", - "acl", - "atime", - "auto", - "bg", - "cto", - "dev", - "diratime", - "exec", - "fg", - "fsc", - "group", - "hard", - "intr", - "iversion", - "lock", - "mand", - "owner", - "posix", - "rdirplus", - "relatime", - "soft", - "strictatime", - "suid", - "tcp", - "udp", - "user", - "users" - ] - - NEGATED_OPTIONS = NEGATABLE_OPTIONS.map{ |o| "no#{o}" } - - # these cannot be negated - # they are not nfs specific BTW - SIMPLE_OPTIONS = [ - "_netdev", - "async", - "bind", - "defaults", - "dirsync", - "loud", - "nofail", - "owner", - "rbind", - "remount", - "ro", - "rw", - "silent", - "sync" - ] - - OPTIONS_WITH_VALUE = [ - "acdirmax", - "acdirmin", - "acdirmin", - "acregmax", - "acregmin", - "actimeo", - "bsize", - "clientaddr", - "context", - "defcontext", - "fscontext", - "minorversion", - "mounthost", - "mountport", - "mountprog", - "mountvers", - "namlen", - "nfsprog", - "nfsvers", - "port", - "proto", - "retrans", - "retry", - "rootcontext", - "rsize", - "sec", - "timeo", - "vers", - "wsize" - ] + # The options should be kept synced with the code that handles them, + # which is not an easy task, as there are many places: + # - util-linux.rpm + # man 8 mount + # https://git.kernel.org/?p=utils/util-linux/util-linux.git;a=history;f=libmount/src/optmap.c + # - nfs-client.rpm (nfs-utils.src.rpm) + # man 5 nfs + # http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=history;f=utils/mount/nfsmount.c + # - kernel: fs/nfs/super.c + # http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=history;f=fs/nfs/super.c + # Note that minorversion in particular is mentioned only in the kernel + # but not in nfs-utils. + + # these can be negated by "no" + NEGATABLE_OPTIONS = [ + "ac", + "acl", + "atime", + "auto", + "bg", + "cto", + "dev", + "diratime", + "exec", + "fg", + "fsc", + "group", + "hard", + "intr", + "iversion", + "lock", + "mand", + "owner", + "posix", + "rdirplus", + "relatime", + "soft", + "strictatime", + "suid", + "tcp", + "udp", + "user", + "users" + ] + + NEGATED_OPTIONS = NEGATABLE_OPTIONS.map{ |o| "no#{o}" } + + # these cannot be negated + # they are not nfs specific BTW + SIMPLE_OPTIONS = [ + "_netdev", + "async", + "bind", + "defaults", + "dirsync", + "loud", + "nofail", + "owner", + "rbind", + "remount", + "ro", + "rw", + "silent", + "sync" + ] + + OPTIONS_WITH_VALUE = [ + "acdirmax", + "acdirmin", + "acdirmin", + "acregmax", + "acregmin", + "actimeo", + "bsize", + "clientaddr", + "context", + "defcontext", + "fscontext", + "minorversion", + "mounthost", + "mountport", + "mountprog", + "mountvers", + "namlen", + "nfsprog", + "nfsvers", + "port", + "proto", + "retrans", + "retry", + "rootcontext", + "rsize", + "sec", + "timeo", + "vers", + "wsize" + ] def main textdomain "nfs" From 4acbc7508295ac32d8c36b1b0bf606302b7d6f8b Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:21:21 +0100 Subject: [PATCH 22/40] rubocop: Style/InfiniteLoop fixed already in 097355dcaa7e405d096f8a743a50b0331109379a --- .rubocop.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index eca3467..62d3c68 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -44,11 +44,6 @@ Style/Documentation: Style/FileName: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Style/InfiniteLoop: - Enabled: false - Style/MethodName: EnforcedStyle: snake_case Exclude: From eed1c5b03160090cf0fc917ad126d47b20a88367 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:29:40 +0100 Subject: [PATCH 23/40] rubocop: Style/FileName, renamed tests, excluded existing sources --- testsuite/tests/{nfs-options.err => nfs_options.err} | 0 testsuite/tests/{nfs-options.out => nfs_options.out} | 0 testsuite/tests/{nfs-options.rb => nfs_options.rb} | 0 testsuite/tests/{r-check.err => r_check.err} | 0 testsuite/tests/{r-check.out => r_check.out} | 0 testsuite/tests/{r-check.rb => r_check.rb} | 0 testsuite/tests/{r-fstab.err => r_fstab.err} | 0 testsuite/tests/{r-fstab.out => r_fstab.out} | 0 testsuite/tests/{r-fstab.rb => r_fstab.rb} | 0 testsuite/tests/{r-spec.err => r_spec.err} | 0 testsuite/tests/{r-spec.out => r_spec.out} | 0 testsuite/tests/{r-spec.rb => r_spec.rb} | 0 testsuite/tests/{r-strip.err => r_strip.err} | 0 testsuite/tests/{r-strip.out => r_strip.out} | 0 testsuite/tests/{r-strip.rb => r_strip.rb} | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename testsuite/tests/{nfs-options.err => nfs_options.err} (100%) rename testsuite/tests/{nfs-options.out => nfs_options.out} (100%) rename testsuite/tests/{nfs-options.rb => nfs_options.rb} (100%) rename testsuite/tests/{r-check.err => r_check.err} (100%) rename testsuite/tests/{r-check.out => r_check.out} (100%) rename testsuite/tests/{r-check.rb => r_check.rb} (100%) rename testsuite/tests/{r-fstab.err => r_fstab.err} (100%) rename testsuite/tests/{r-fstab.out => r_fstab.out} (100%) rename testsuite/tests/{r-fstab.rb => r_fstab.rb} (100%) rename testsuite/tests/{r-spec.err => r_spec.err} (100%) rename testsuite/tests/{r-spec.out => r_spec.out} (100%) rename testsuite/tests/{r-spec.rb => r_spec.rb} (100%) rename testsuite/tests/{r-strip.err => r_strip.err} (100%) rename testsuite/tests/{r-strip.out => r_strip.out} (100%) rename testsuite/tests/{r-strip.rb => r_strip.rb} (100%) diff --git a/testsuite/tests/nfs-options.err b/testsuite/tests/nfs_options.err similarity index 100% rename from testsuite/tests/nfs-options.err rename to testsuite/tests/nfs_options.err diff --git a/testsuite/tests/nfs-options.out b/testsuite/tests/nfs_options.out similarity index 100% rename from testsuite/tests/nfs-options.out rename to testsuite/tests/nfs_options.out diff --git a/testsuite/tests/nfs-options.rb b/testsuite/tests/nfs_options.rb similarity index 100% rename from testsuite/tests/nfs-options.rb rename to testsuite/tests/nfs_options.rb diff --git a/testsuite/tests/r-check.err b/testsuite/tests/r_check.err similarity index 100% rename from testsuite/tests/r-check.err rename to testsuite/tests/r_check.err diff --git a/testsuite/tests/r-check.out b/testsuite/tests/r_check.out similarity index 100% rename from testsuite/tests/r-check.out rename to testsuite/tests/r_check.out diff --git a/testsuite/tests/r-check.rb b/testsuite/tests/r_check.rb similarity index 100% rename from testsuite/tests/r-check.rb rename to testsuite/tests/r_check.rb diff --git a/testsuite/tests/r-fstab.err b/testsuite/tests/r_fstab.err similarity index 100% rename from testsuite/tests/r-fstab.err rename to testsuite/tests/r_fstab.err diff --git a/testsuite/tests/r-fstab.out b/testsuite/tests/r_fstab.out similarity index 100% rename from testsuite/tests/r-fstab.out rename to testsuite/tests/r_fstab.out diff --git a/testsuite/tests/r-fstab.rb b/testsuite/tests/r_fstab.rb similarity index 100% rename from testsuite/tests/r-fstab.rb rename to testsuite/tests/r_fstab.rb diff --git a/testsuite/tests/r-spec.err b/testsuite/tests/r_spec.err similarity index 100% rename from testsuite/tests/r-spec.err rename to testsuite/tests/r_spec.err diff --git a/testsuite/tests/r-spec.out b/testsuite/tests/r_spec.out similarity index 100% rename from testsuite/tests/r-spec.out rename to testsuite/tests/r_spec.out diff --git a/testsuite/tests/r-spec.rb b/testsuite/tests/r_spec.rb similarity index 100% rename from testsuite/tests/r-spec.rb rename to testsuite/tests/r_spec.rb diff --git a/testsuite/tests/r-strip.err b/testsuite/tests/r_strip.err similarity index 100% rename from testsuite/tests/r-strip.err rename to testsuite/tests/r_strip.err diff --git a/testsuite/tests/r-strip.out b/testsuite/tests/r_strip.out similarity index 100% rename from testsuite/tests/r-strip.out rename to testsuite/tests/r_strip.out diff --git a/testsuite/tests/r-strip.rb b/testsuite/tests/r_strip.rb similarity index 100% rename from testsuite/tests/r-strip.rb rename to testsuite/tests/r_strip.rb From f326b9bef1a10806efa9e097e1f6ead4a9397479 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:30:41 +0100 Subject: [PATCH 24/40] rubocop: Style/MultilineBlockLayout fixed probably in b16c5e149b19903569990369b37a2df9753cc3c0 --- .rubocop.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 62d3c68..b35f893 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -39,10 +39,12 @@ Style/Documentation: Exclude: - testsuite/tests/*.rb -# Offense count: 9 -# Configuration parameters: Exclude. Style/FileName: - Enabled: false + Exclude: + - src/clients/nfs-client.rb + - src/clients/nfs-client4part.rb + - src/modules/Nfs.rb + - src/modules/NfsOptions.rb Style/MethodName: EnforcedStyle: snake_case @@ -54,11 +56,6 @@ Style/MethodName: - src/include/nfs/wizards.rb - src/modules/Nfs.rb -# Offense count: 2 -# Cop supports --auto-correct. -Style/MultilineBlockLayout: - Enabled: false - # Offense count: 4 Style/MultilineTernaryOperator: Enabled: false From 9023c7f6e5a096bf0d00865ced1dc9320a2c7838 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 16:51:51 +0100 Subject: [PATCH 25/40] rubocop: Style/MultilineTernaryOperator --- .rubocop.yml | 4 ---- src/modules/Nfs.rb | 27 ++++++++++++++------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b35f893..19e04a5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -56,10 +56,6 @@ Style/MethodName: - src/include/nfs/wizards.rb - src/modules/Nfs.rb -# Offense count: 4 -Style/MultilineTernaryOperator: - Enabled: false - # Offense count: 12 # Cop supports --auto-correct. Style/NegatedIf: diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index ce89cd4..d846575 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -247,9 +247,8 @@ def Export # @param [String] s a string or nil # @return escaped string or nil def EscapeSpaces1(s) - s == nil ? - nil : - Builtins.mergestring(Builtins.splitstring(s, " "), "\\040") + return nil if s.nil? + s.gsub(/ /) { "\\040" } # block prevents interpreting \ as backreference end # Escape spaces " " -> "\\040" in all values of all entries @@ -260,9 +259,11 @@ def EscapeSpaces(entries) Builtins.maplist(entries) do |entry| Builtins.mapmap(entry) do |key, value| { - key => Ops.is_string?(value) ? - EscapeSpaces1(Convert.to_string(value)) : - value + key => if Ops.is_string?(value) + EscapeSpaces1(Convert.to_string(value)) + else + value + end } end end @@ -285,9 +286,11 @@ def UnescapeSpaces(entries) Builtins.maplist(entries) do |entry| Builtins.mapmap(entry) do |key, value| { - key => Ops.is_string?(value) ? - UnescapeSpaces1(Convert.to_string(value)) : - value + key => if Ops.is_string?(value) + UnescapeSpaces1(Convert.to_string(value)) + else + value + end } end end @@ -600,10 +603,8 @@ def Mount(server, share, mpoint, options, type) # build mount command command = Builtins.sformat( "/bin/mount %1 %2 %3:%4 %5", - Ops.greater_than(Builtins.size(options), 0) ? - Ops.add("-o ", options) : - "", - Ops.add("-t ", Ops.greater_than(Builtins.size(type), 0) ? type : "nfs"), + options.to_s == "" ? "" : "-o #{options}", + "-t #{type.to_s == "" ? "nfs" : type}", server, share, mpoint From 29a3e8d47dc3c6acb2298735118fafe342ac8940 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:00:23 +0100 Subject: [PATCH 26/40] rubocop: Style/NilComparison --- .rubocop.yml | 8 +------- src/include/nfs/routines.rb | 2 +- src/include/nfs/ui.rb | 6 +++--- src/modules/Nfs.rb | 8 ++++---- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 19e04a5..71f5118 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -56,16 +56,10 @@ Style/MethodName: - src/include/nfs/wizards.rb - src/modules/Nfs.rb -# Offense count: 12 -# Cop supports --auto-correct. +# "unless" has a different connotation than "if not" Style/NegatedIf: Enabled: false -# Offense count: 11 -# Cop supports --auto-correct. -Style/NilComparison: - Enabled: false - # Offense count: 11 # Cop supports --auto-correct. # Configuration parameters: IncludeSemanticChanges. diff --git a/src/include/nfs/routines.rb b/src/include/nfs/routines.rb index daa627f..342cbf8 100644 --- a/src/include/nfs/routines.rb +++ b/src/include/nfs/routines.rb @@ -22,7 +22,7 @@ def SpecToServPath(spec) serv = "" # no :/ inside => : or [/] - if path_begin == nil + if path_begin.nil? if spec == Ops.add( Builtins.filterchars(spec, Ops.add("-_.", String.CAlnum)), diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index 97cbbd6..8bf3247 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -312,13 +312,13 @@ def GetFstabEntry(fstab_ent, existing) ret = UI.UserInput if ret == :choose - if @hosts == nil + if @hosts.nil? # label message UI.OpenDialog(Label(_("Scanning for hosts on this LAN..."))) @hosts = Nfs.ProbeServers UI.CloseDialog end - if @hosts == [] || @hosts == nil + if @hosts == [] || @hosts.nil? # Translators: 1st part of error message error_msg = _("No NFS server has been found on your network.") @@ -363,7 +363,7 @@ def GetFstabEntry(fstab_ent, existing) UI.ChangeWidget(Id(:pathent), :Value, dir) if dir != nil elsif ret == :browse dir = Convert.to_string(UI.QueryWidget(Id(:mountent), :Value)) - dir = "/" if dir == nil || Builtins.size(dir) == 0 + dir = "/" if dir.nil? || Builtins.size(dir) == 0 # heading for a directory selection dialog dir = UI.AskForExistingDirectory(dir, _("Select the Mount Point")) diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index d846575..0187c64 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -553,10 +553,10 @@ def Mount(server, share, mpoint, options, type) end # mount to temporary directory if mpoint is nil - if mpoint == nil + if mpoint.nil? tmpdir = Convert.to_string(SCR.Read(path(".target.tmpdir"))) - if tmpdir == nil || tmpdir == "" + if tmpdir.nil? || tmpdir == "" Builtins.y2security("Warning: using /tmp directory!") tmpdir = "/tmp" end @@ -590,7 +590,7 @@ def Mount(server, share, mpoint, options, type) end # create mount point if it doesn't exist - if SCR.Read(path(".target.dir"), mpoint) == nil + if SCR.Read(path(".target.dir"), mpoint).nil? if !Convert.to_boolean(SCR.Execute(path(".target.mkdir"), mpoint)) Builtins.y2warning("cannot create mount point %1", mpoint) return nil @@ -721,7 +721,7 @@ def ProbeExports(server, v4) ) end - dirs = ["internal error"] if dirs == nil + dirs = ["internal error"] if dirs.nil? deep_copy(dirs) end From 18bed3e61ad83b29e29b154d21203dc8a91b5550 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:09:16 +0100 Subject: [PATCH 27/40] rubocop: Style/NonNilCheck: IncludeSemanticChanges --- .rubocop.yml | 6 ++---- src/clients/nfs-client4part.rb | 2 +- src/include/nfs/routines.rb | 2 +- src/include/nfs/ui.rb | 14 +++++++------- src/modules/Nfs.rb | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 71f5118..c0ab861 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -60,11 +60,9 @@ Style/MethodName: Style/NegatedIf: Enabled: false -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: IncludeSemanticChanges. Style/NonNilCheck: - Enabled: false + Enabled: true + IncludeSemanticChanges: true # Offense count: 1 # Cop supports --auto-correct. diff --git a/src/clients/nfs-client4part.rb b/src/clients/nfs-client4part.rb index 9ce713b..23b426c 100644 --- a/src/clients/nfs-client4part.rb +++ b/src/clients/nfs-client4part.rb @@ -74,7 +74,7 @@ def ToStorage(entry) entry = deep_copy(entry) ret = {} - if entry != nil && entry != {} + if entry && entry != {} ret = { "device" => Ops.get_string(entry, "spec", ""), "mount" => Ops.get_string(entry, "file", ""), diff --git a/src/include/nfs/routines.rb b/src/include/nfs/routines.rb index 342cbf8..95cb3bc 100644 --- a/src/include/nfs/routines.rb +++ b/src/include/nfs/routines.rb @@ -33,7 +33,7 @@ def SpecToServPath(spec) end end - if path_begin != nil + if path_begin serv = Builtins.substring(spec, 0, path_begin) spec = Builtins.substring(spec, Ops.add(path_begin, 1)) end diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index 8bf3247..adc2391 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -147,7 +147,7 @@ def ProposeHostname ret = "" cur_domain = Hostname.CurrentDomain - ret = Ops.add("nfs.", cur_domain) if cur_domain != nil || cur_domain != "" + ret = Ops.add("nfs.", cur_domain) if cur_domain || cur_domain != "" ret end @@ -205,7 +205,7 @@ def GetFstabEntry(fstab_ent, existing) servers = [] old = "" - if fstab_ent != nil + if fstab_ent couple = SpecToServPath(Ops.get_string(fstab_ent, "spec", "")) server = Ops.get_string(couple, 0, "") pth = Ops.get_string(couple, 1, "") @@ -336,7 +336,7 @@ def GetFstabEntry(fstab_ent, existing) Report.Error(error_msg) else host = ChooseHostName(@hosts) - UI.ChangeWidget(Id(:serverent), :Value, host) if host != nil + UI.ChangeWidget(Id(:serverent), :Value, host) if host end elsif ret == :pathent_list server2 = Convert.to_string(UI.QueryWidget(Id(:serverent), :Value)) @@ -360,7 +360,7 @@ def GetFstabEntry(fstab_ent, existing) UI.CloseDialog dir = ChooseExport(dirs) - UI.ChangeWidget(Id(:pathent), :Value, dir) if dir != nil + UI.ChangeWidget(Id(:pathent), :Value, dir) if dir elsif ret == :browse dir = Convert.to_string(UI.QueryWidget(Id(:mountent), :Value)) dir = "/" if dir.nil? || Builtins.size(dir) == 0 @@ -368,7 +368,7 @@ def GetFstabEntry(fstab_ent, existing) # heading for a directory selection dialog dir = UI.AskForExistingDirectory(dir, _("Select the Mount Point")) - if dir != nil && Ops.greater_than(Builtins.size(dir), 0) + if dir && Ops.greater_than(Builtins.size(dir), 0) UI.ChangeWidget(Id(:mountent), :Value, dir) end elsif ret == :ok @@ -597,7 +597,7 @@ def HandleEvent(widget) ) ) - if entry != nil + if entry @nfs_entries = Builtins.add(@nfs_entries, entry) @modify_line = deep_copy(entry) EnableDisableButtons() @@ -618,7 +618,7 @@ def HandleEvent(widget) :to => "list " ) # Default values ) - if entry != nil + if entry count2 = 0 @nfs_entries = Builtins.maplist(@nfs_entries) do |ent| count2 = Ops.add(count2, 1) diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index 0187c64..ad4c857 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -177,7 +177,7 @@ def ImportAny(settings) global_options = global_options_ref.value entries = entries_ref.value - return false if Builtins.find(entries) { |e| !ValidateAyNfsEntry(e) } != nil + return false if Builtins.find(entries) { |e| !ValidateAyNfsEntry(e) } entries = FillEntriesDefaults(entries) @@ -194,7 +194,7 @@ def ImportAny(settings) # vfstype can override a missing enable_nfs4 @nfs4_enabled = true if Builtins.find(entries) do |entry| Ops.get_string(entry, "vfstype", "") == "nfs4" - end != nil + end @nfs_entries = Builtins.maplist(entries) do |entry| { From 6c98b4c81dc5c04bf2d02c1213a4eda61e87d95c Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:11:42 +0100 Subject: [PATCH 28/40] rubocop: Style/SpaceAfterNot Style/SpaceBeforeBlockBraces --- .rubocop.yml | 11 ----------- src/modules/NfsOptions.rb | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c0ab861..287e62a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -64,17 +64,6 @@ Style/NonNilCheck: Enabled: true IncludeSemanticChanges: true -# Offense count: 1 -# Cop supports --auto-correct. -Style/SpaceAfterNot: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/SpaceBeforeBlockBraces: - Enabled: false - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. diff --git a/src/modules/NfsOptions.rb b/src/modules/NfsOptions.rb index 23d378a..44fbf96 100644 --- a/src/modules/NfsOptions.rb +++ b/src/modules/NfsOptions.rb @@ -51,7 +51,7 @@ class NfsOptionsClass < Module "users" ] - NEGATED_OPTIONS = NEGATABLE_OPTIONS.map{ |o| "no#{o}" } + NEGATED_OPTIONS = NEGATABLE_OPTIONS.map { |o| "no#{o}" } # these cannot be negated # they are not nfs specific BTW @@ -150,7 +150,7 @@ def validate(options) # To translators: error popup error_message = _("Unexpected value '%{value}' for option '%{key}'") % { :value => value, :key => key } # All unknown options - elsif ! OPTIONS_WITH_VALUE.include?(key) + elsif !OPTIONS_WITH_VALUE.include?(key) # To translators: error popup error_message = _("Unknown option: '%{key}'") % { :key => key } # All known ones with badly specified values From f380d9e9c75760aca72a1b58c86920babc1a4471 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:12:42 +0100 Subject: [PATCH 29/40] rubocop: Style/TrailingComma --- .rubocop.yml | 6 ------ test/nfs_options_test.rb | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 287e62a..9db8916 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -64,12 +64,6 @@ Style/NonNilCheck: Enabled: true IncludeSemanticChanges: true -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. -Style/TrailingComma: - Enabled: false - # Offense count: 4 # Cop supports --auto-correct. Style/TrailingWhitespace: diff --git a/test/nfs_options_test.rb b/test/nfs_options_test.rb index f7fa9ff..5f38138 100755 --- a/test/nfs_options_test.rb +++ b/test/nfs_options_test.rb @@ -30,7 +30,7 @@ "noatime,port=", "mountvers=", "mountvers,=port=23", - "nolock,rsize=", + "nolock,rsize=" ].each do |options| returned = Yast::NfsOptions.validate(options) expect(returned).to start_with("Empty value"), "options '#{options}' returned '#{returned}'" @@ -40,7 +40,7 @@ it "returns 'Unexpected value' error message on options that do not expect key=value but some value is present" do [ "nolock,intr=bogus", - "nosuid=true", + "nosuid=true" ].each do |options| returned = Yast::NfsOptions.validate(options) expect(returned).to start_with("Unexpected value"), "options '#{options}' returned '#{returned}'" @@ -51,7 +51,7 @@ [ "noatime,port=dort=fort", "mountvers=port=23", - "nolock,retrans=trans=trans", + "nolock,retrans=trans=trans" ].each do |options| returned = Yast::NfsOptions.validate(options) expect(returned).to start_with("Invalid option"), "options '#{options}' returned '#{returned}'" @@ -65,7 +65,7 @@ "nolock, bg", "nolock,unknownoption", "nolock,unknownassignment=true", - "nolock,two=equal=signs", + "nolock,two=equal=signs" ].each do |options| returned = Yast::NfsOptions.validate(options) expect(returned).to start_with("Unknown option"), "options '#{options}' returned '#{returned}'" From d4336bb57245804effc01a9a7ecb6eef3fbd3209 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:13:56 +0100 Subject: [PATCH 30/40] rubocop: Style/TrailingWhitespace --- .rubocop.yml | 5 ----- src/clients/nfs.rb | 2 +- src/clients/nfs_auto.rb | 2 +- src/modules/Nfs.rb | 2 +- testsuite/tests/readwrite2.rb | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9db8916..98a3830 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -64,11 +64,6 @@ Style/NonNilCheck: Enabled: true IncludeSemanticChanges: true -# Offense count: 4 -# Cop supports --auto-correct. -Style/TrailingWhitespace: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist. diff --git a/src/clients/nfs.rb b/src/clients/nfs.rb index 84c3970..5c2108b 100644 --- a/src/clients/nfs.rb +++ b/src/clients/nfs.rb @@ -125,7 +125,7 @@ def main Builtins.y2milestone("NFS module finished") Builtins.y2milestone("----------------------------------------") - deep_copy(@ret) + deep_copy(@ret) # EOF end diff --git a/src/clients/nfs_auto.rb b/src/clients/nfs_auto.rb index f029488..2672cf2 100644 --- a/src/clients/nfs_auto.rb +++ b/src/clients/nfs_auto.rb @@ -85,7 +85,7 @@ def main Builtins.y2milestone("Nfs auto finished") Builtins.y2milestone("----------------------------------------") - deep_copy(@ret) + deep_copy(@ret) # EOF end diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index ad4c857..5d30fde 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -632,7 +632,7 @@ def Unmount(mpoint) type = Ops.get_string(m, "vfstype") file = Ops.get_string(m, "file") found = true if (type == "nfs" || type == "nfs4") && file == mpoint - end + end if found command = Builtins.sformat("/bin/umount %1", mpoint) diff --git a/testsuite/tests/readwrite2.rb b/testsuite/tests/readwrite2.rb index 2bb3919..b163f5d 100644 --- a/testsuite/tests/readwrite2.rb +++ b/testsuite/tests/readwrite2.rb @@ -172,7 +172,7 @@ def main TEST(->() { Nfs.Read }, [@EMPTY3, @WRITE, @EXECUTE], nil) # fstab unchanged - so, leave services stopped DUMP("\nWrite - nfs not used; leave services stopped\n") - TEST(->() { Nfs.Write }, [@EMPTY3, @WRITE, @EXECUTE], nil) + TEST(->() { Nfs.Write }, [@EMPTY3, @WRITE, @EXECUTE], nil) # // nfs and portmap are running # DUMP ("\nRead - services are running\n"); From 85fbad6ed46cfc5149be3921e8689a0df65bfd35 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:17:20 +0100 Subject: [PATCH 31/40] rubocop: Style/TrivialAccessors disabled inline --- .rubocop.yml | 6 ------ src/modules/Nfs.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 98a3830..63a03ca 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -64,12 +64,6 @@ Style/NonNilCheck: Enabled: true IncludeSemanticChanges: true -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist. -Style/TrivialAccessors: - Enabled: false - Style/VariableName: EnforcedStyle: snake_case Exclude: diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index 5d30fde..c5bea8c 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -62,7 +62,7 @@ def SetModified # Functions which returns if the settings were modified # @return [Boolean] settings were modified - def GetModified + def GetModified # rubocop:disable Style/TrivialAccessors @modified end From 4183ff5227212633dca2b9ef1909b9fdf455e471 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:21:52 +0100 Subject: [PATCH 32/40] rubocop: remove config that is no longer needed --- .rubocop.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 63a03ca..2751e5e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,10 +8,6 @@ inherit_from: .rubocop_yast_style.yml -# Offense count: 4 -Metrics/BlockNesting: - Max: 4 - # Offense count: 5 # Configuration parameters: CountComments. Metrics/ClassLength: @@ -60,10 +56,6 @@ Style/MethodName: Style/NegatedIf: Enabled: false -Style/NonNilCheck: - Enabled: true - IncludeSemanticChanges: true - Style/VariableName: EnforcedStyle: snake_case Exclude: From 50596adef0a9d41a280f40e94cd71ea2cf3c97d3 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:23:50 +0100 Subject: [PATCH 33/40] rubocop: updated metrics, slightly stricter --- .rubocop.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2751e5e..a5a90e5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ # This configuration was generated by `rubocop --auto-gen-config` -# on 2014-11-26 13:17:00 +0100 using RuboCop version 0.26.1. +# on 2014-11-26 17:19:37 +0100 using RuboCop version 0.26.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -11,18 +11,18 @@ inherit_from: # Offense count: 5 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 521 + Max: 513 # Offense count: 13 Metrics/CyclomaticComplexity: Max: 31 -# Offense count: 56 +# Offense count: 49 # Configuration parameters: AllowURI, URISchemes. Metrics/LineLength: Max: 116 -# Offense count: 46 +# Offense count: 47 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 223 From 01214731b3018917a93f7e3af077ce3cef7a55ac Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:37:26 +0100 Subject: [PATCH 34/40] rubocop: config updated for 0.27.1. --- .rubocop.yml | 10 +++++++++- .rubocop_yast_style.yml | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index a5a90e5..106458d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ # This configuration was generated by `rubocop --auto-gen-config` -# on 2014-11-26 17:19:37 +0100 using RuboCop version 0.26.1. +# on 2014-11-26 17:28:40 +0100 using RuboCop version 0.27.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -8,6 +8,10 @@ inherit_from: .rubocop_yast_style.yml +# Offense count: 34 +Metrics/AbcSize: + Max: 220 + # Offense count: 5 # Configuration parameters: CountComments. Metrics/ClassLength: @@ -52,6 +56,10 @@ Style/MethodName: - src/include/nfs/wizards.rb - src/modules/Nfs.rb +# the autocorrected code looks uglier; autocorrector can loop endlessly +Style/MultilineOperationIndentation: + Enabled: false + # "unless" has a different connotation than "if not" Style/NegatedIf: Enabled: false diff --git a/.rubocop_yast_style.yml b/.rubocop_yast_style.yml index 0cdfdab..ac13443 100644 --- a/.rubocop_yast_style.yml +++ b/.rubocop_yast_style.yml @@ -7,6 +7,9 @@ Style/StringLiterals: EnforcedStyle: double_quotes +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes + # YCP Killer used rockets Style/HashSyntax: EnforcedStyle: hash_rockets From 8cec1eb25a8b2eebe5fbfaeb688972efa908fdfc Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 26 Nov 2014 17:52:42 +0100 Subject: [PATCH 35/40] rubocop: enable in Travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8ad5dd9..504981b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,11 @@ before_install: # disable rvm, use system Ruby - rvm reset - wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh - - sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2" -g "rspec:2.14.1 yast-rake gettext" + - sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2" -g "rspec:2.14.1 yast-rake gettext rubocop" script: - rake check:syntax - rake check:pot + - rubocop - make -f Makefile.cvs - make - sudo make install From 8c32bf33b8c29fa845e8edbe08df9ee939c0d345 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Mon, 1 Dec 2014 13:27:07 +0100 Subject: [PATCH 36/40] rubocop: rearranged the config after review Style/HashSyntax: do enforce it, for new code Style/MultilineOperationIndentation: indented is right Style/VariableName: Style/MethodName: do not spell out snake_case which is the default --- .rubocop.yml | 23 ++++++++++------------- .rubocop_yast_style.yml | 6 +++--- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 106458d..54792e4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,3 @@ -# This configuration was generated by `rubocop --auto-gen-config` -# on 2014-11-26 17:28:40 +0100 using RuboCop version 0.27.1. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - inherit_from: .rubocop_yast_style.yml @@ -46,8 +39,17 @@ Style/FileName: - src/modules/Nfs.rb - src/modules/NfsOptions.rb +# YCP Killer used rockets +Style/HashSyntax: + Exclude: + - src/clients/nfs.rb + - src/clients/nfs_auto.rb + - src/include/nfs/ui.rb + - src/include/nfs/wizards.rb + - src/modules/Nfs.rb + - src/modules/NfsOptions.rb + Style/MethodName: - EnforcedStyle: snake_case Exclude: - src/clients/nfs-client4part.rb - src/clients/nfs.rb @@ -56,15 +58,10 @@ Style/MethodName: - src/include/nfs/wizards.rb - src/modules/Nfs.rb -# the autocorrected code looks uglier; autocorrector can loop endlessly -Style/MultilineOperationIndentation: - Enabled: false - # "unless" has a different connotation than "if not" Style/NegatedIf: Enabled: false Style/VariableName: - EnforcedStyle: snake_case Exclude: - testsuite/tests/*.rb diff --git a/.rubocop_yast_style.yml b/.rubocop_yast_style.yml index ac13443..2335188 100644 --- a/.rubocop_yast_style.yml +++ b/.rubocop_yast_style.yml @@ -10,9 +10,9 @@ Style/StringLiterals: Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes -# YCP Killer used rockets -Style/HashSyntax: - EnforcedStyle: hash_rockets +# Is there any justification for "aligned" which is the default? +Style/MultilineOperationIndentation: + EnforcedStyle: indented # https://github.com/SUSE/style-guides/blob/master/Ruby.md#arrays Style/WordArray: From 7957ec1e9724c0bc4af46a505a771159678dc088 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Mon, 1 Dec 2014 13:28:22 +0100 Subject: [PATCH 37/40] better type info in doc comments --- src/modules/NfsOptions.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/NfsOptions.rb b/src/modules/NfsOptions.rb index 44fbf96..6c40537 100644 --- a/src/modules/NfsOptions.rb +++ b/src/modules/NfsOptions.rb @@ -111,7 +111,7 @@ def main # Parse to an internal representation: # Simply split by commas, but "defaults" is represented by the empty list # @param [String] options a fstab option string - # @return [Array] of individual options + # @return [Array] of individual options def from_string(options) return [] if options == "defaults" @@ -120,7 +120,7 @@ def from_string(options) # Convert list of individual options to a fstab option string # @param [Array] option_list list of individual options - # @return a fstab option string + # @return [String] a fstab option string def to_string(option_list) return "defaults" if option_list.empty? @@ -134,7 +134,7 @@ def non_value_option?(option) # Checks the nfs options for /etc/fstab: # nonempty, comma separated list of foo,nofoo,bar=baz (see nfs(5)) # @param [String] options options - # @return a translated string with error message, emtpy string if ok + # @return [String] a translated string with an error message, emtpy if OK def validate(options) # To translators: error popup return _("Empty option strings are not allowed.") if options.empty? @@ -170,8 +170,8 @@ def validate(options) end # FIXME: factor out get_nfs4(vfstype, options) (depending on n::o)! - # * @param options fstab option string - # * @return is version >= 4.1 enabled + # @param options [String] fstab option string + # @return [Boolean] is version >= 4.1 enabled def get_nfs41(options) option_list = from_string(options) @@ -183,7 +183,7 @@ def get_nfs41(options) # FIXME: vfstype=nfs4 is deprecated in favor of nfsvers=4 (aka vers=4) # @param [String] options fstab option string # @param [Boolean] nfs41 is version >= 4.1 enabled - # @return new fstab option string + # @return [String] new fstab option string def set_nfs41(options, nfs41) # don't mutate the string unnecessarily return options if get_nfs41(options) == nfs41 From 183b84324b57e579ac6120898497b4b205d0f919 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Mon, 1 Dec 2014 13:34:53 +0100 Subject: [PATCH 38/40] Fixed a condition that was always true. The impact of the bug was small because other code queried DNS anyway and filtered out the nonexistent host name. --- src/include/nfs/ui.rb | 2 +- src/modules/Nfs.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index adc2391..34c54d8 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -147,7 +147,7 @@ def ProposeHostname ret = "" cur_domain = Hostname.CurrentDomain - ret = Ops.add("nfs.", cur_domain) if cur_domain || cur_domain != "" + ret = "nfs.#{cur_domain}" if cur_domain && cur_domain != "" ret end diff --git a/src/modules/Nfs.rb b/src/modules/Nfs.rb index c5bea8c..1fad787 100644 --- a/src/modules/Nfs.rb +++ b/src/modules/Nfs.rb @@ -387,7 +387,7 @@ def WriteOnly Convert.convert( Builtins.union( entry, - "freq" => 0, "passno" => 0 # "vfstype": "nfs", + "freq" => 0, "passno" => 0 ), :from => "map", :to => "map " From 5351b49a95daa23870462e4086b4c5612be871ae Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 10 Dec 2014 12:41:53 +0100 Subject: [PATCH 39/40] rubocop: Style/LineEndConcatenation in an unusual case --- src/include/nfs/ui.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/nfs/ui.rb b/src/include/nfs/ui.rb index 34c54d8..9c66b0c 100644 --- a/src/include/nfs/ui.rb +++ b/src/include/nfs/ui.rb @@ -435,9 +435,9 @@ def GetFstabEntry(fstab_ent, existing) helptext = Ops.add( helptext, _( - "

\t\t\n" + + "

\t\t\n" \ "For Mount Point, enter the path in the local " \ - "file system where the directory should be mounted. With\n" + + "file system where the directory should be mounted. With\n" \ "Browse, select your mount point\n" \ "interactively.

" ) From ee4a3c04a7aa49947f831b8f44f0456b19c5c828 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Wed, 10 Dec 2014 13:05:03 +0100 Subject: [PATCH 40/40] rubocop: more common style (from yast2-registration) --- .rubocop.yml | 4 ---- .rubocop_yast_style.yml | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 54792e4..5bbf3e9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -58,10 +58,6 @@ Style/MethodName: - src/include/nfs/wizards.rb - src/modules/Nfs.rb -# "unless" has a different connotation than "if not" -Style/NegatedIf: - Enabled: false - Style/VariableName: Exclude: - testsuite/tests/*.rb diff --git a/.rubocop_yast_style.yml b/.rubocop_yast_style.yml index 2335188..e8d71ea 100644 --- a/.rubocop_yast_style.yml +++ b/.rubocop_yast_style.yml @@ -17,3 +17,25 @@ Style/MultilineOperationIndentation: # https://github.com/SUSE/style-guides/blob/master/Ruby.md#arrays Style/WordArray: Enabled: false + +# align arrows: +# "foo" => true +# "foo_bar" => false +Style/AlignHash: + EnforcedHashRocketStyle: table + +# no extra indentation for multiline function calls +Style/AlignParameters: + EnforcedStyle: with_fixed_indentation + +# no extra indentation for case +Style/CaseIndentation: + IndentWhenRelativeTo: end + +# "unless" has a different connotation than "if not" +Style/NegatedIf: + Enabled: false + +# use "raise" instead of "fail" +Style/SignalException: + EnforcedStyle: only_raise