From fedc008b8e787becb94ebfad5022f4d70f569b97 Mon Sep 17 00:00:00 2001 From: Alexander Salmin Date: Tue, 28 Nov 2017 21:50:53 +0100 Subject: [PATCH] Improve syntax --- spec/fixtures/test/manifests/absolute_path.pp | 2 +- spec/fixtures/test/manifests/absolutepath.pp | 4 ++-- spec/fixtures/test/manifests/array.pp | 2 +- spec/fixtures/test/manifests/bool.pp | 2 +- spec/fixtures/test/manifests/deftype.pp | 3 ++- spec/fixtures/test/manifests/filemode.pp | 2 +- spec/fixtures/test/manifests/float.pp | 2 +- spec/fixtures/test/manifests/hash.pp | 2 +- spec/fixtures/test/manifests/httpsurl.pp | 2 +- spec/fixtures/test/manifests/httpurl.pp | 2 +- spec/fixtures/test/manifests/integer.pp | 2 +- spec/fixtures/test/manifests/ip_address.pp | 2 +- spec/fixtures/test/manifests/ipv4.pp | 2 +- spec/fixtures/test/manifests/ipv6.pp | 2 +- spec/fixtures/test/manifests/numeric.pp | 2 +- spec/fixtures/test/manifests/string.pp | 2 +- spec/fixtures/test/manifests/unixpath.pp | 2 +- spec/fixtures/test/manifests/windowspath.pp | 2 +- types/compat/absolute_path.pp | 2 +- types/compat/integer.pp | 2 +- types/compat/ipv4.pp | 2 +- types/compat/ipv6.pp | 2 +- types/compat/numeric.pp | 2 +- 23 files changed, 25 insertions(+), 24 deletions(-) diff --git a/spec/fixtures/test/manifests/absolute_path.pp b/spec/fixtures/test/manifests/absolute_path.pp index d77f6bded..e61c0564a 100644 --- a/spec/fixtures/test/manifests/absolute_path.pp +++ b/spec/fixtures/test/manifests/absolute_path.pp @@ -2,5 +2,5 @@ class test::absolute_path( Stdlib::Compat::Absolute_path $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/absolutepath.pp b/spec/fixtures/test/manifests/absolutepath.pp index 83214711d..e0a9e1b91 100644 --- a/spec/fixtures/test/manifests/absolutepath.pp +++ b/spec/fixtures/test/manifests/absolutepath.pp @@ -1,6 +1,6 @@ -# Class to test the Stdlib::Absolutepath type. Not to be confused with Stdlib::Compat::Absolute_path. +# Class to test the Stdlib::Absolutepath type. Not to be confused with Stdlib::Compat::Absolute_path class test::absolutepath( Stdlib::Absolutepath $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/array.pp b/spec/fixtures/test/manifests/array.pp index 84b6a5b62..54285046c 100644 --- a/spec/fixtures/test/manifests/array.pp +++ b/spec/fixtures/test/manifests/array.pp @@ -3,6 +3,6 @@ Stdlib::Compat::Array $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/bool.pp b/spec/fixtures/test/manifests/bool.pp index ab5b5ea1a..39522248a 100644 --- a/spec/fixtures/test/manifests/bool.pp +++ b/spec/fixtures/test/manifests/bool.pp @@ -3,6 +3,6 @@ Stdlib::Compat::Bool $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/deftype.pp b/spec/fixtures/test/manifests/deftype.pp index 825f8fe2d..5115615e2 100644 --- a/spec/fixtures/test/manifests/deftype.pp +++ b/spec/fixtures/test/manifests/deftype.pp @@ -1,3 +1,4 @@ +# Class to test deftype define test::deftype($param = 'foo') { - notify { "deftype: $title": } + notify { "deftype: ${title}": } } diff --git a/spec/fixtures/test/manifests/filemode.pp b/spec/fixtures/test/manifests/filemode.pp index 56864072d..67d501761 100644 --- a/spec/fixtures/test/manifests/filemode.pp +++ b/spec/fixtures/test/manifests/filemode.pp @@ -2,5 +2,5 @@ class test::filemode ( Stdlib::Filemode $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/float.pp b/spec/fixtures/test/manifests/float.pp index 03a603d57..db8f5f032 100644 --- a/spec/fixtures/test/manifests/float.pp +++ b/spec/fixtures/test/manifests/float.pp @@ -3,6 +3,6 @@ Stdlib::Compat::Float $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/hash.pp b/spec/fixtures/test/manifests/hash.pp index c243570fc..fcc4f924f 100644 --- a/spec/fixtures/test/manifests/hash.pp +++ b/spec/fixtures/test/manifests/hash.pp @@ -3,6 +3,6 @@ Stdlib::Compat::Hash $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/httpsurl.pp b/spec/fixtures/test/manifests/httpsurl.pp index 9d6b92de5..8bf2228a9 100644 --- a/spec/fixtures/test/manifests/httpsurl.pp +++ b/spec/fixtures/test/manifests/httpsurl.pp @@ -2,5 +2,5 @@ class test::httpsurl( Stdlib::HTTPSUrl $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/httpurl.pp b/spec/fixtures/test/manifests/httpurl.pp index abf869ea4..cb9d7c339 100644 --- a/spec/fixtures/test/manifests/httpurl.pp +++ b/spec/fixtures/test/manifests/httpurl.pp @@ -2,5 +2,5 @@ class test::httpurl( Stdlib::HTTPUrl $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/integer.pp b/spec/fixtures/test/manifests/integer.pp index a4f26df48..faadf8957 100644 --- a/spec/fixtures/test/manifests/integer.pp +++ b/spec/fixtures/test/manifests/integer.pp @@ -3,6 +3,6 @@ Stdlib::Compat::Integer $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/ip_address.pp b/spec/fixtures/test/manifests/ip_address.pp index bbbd80457..8cfd1d3e1 100644 --- a/spec/fixtures/test/manifests/ip_address.pp +++ b/spec/fixtures/test/manifests/ip_address.pp @@ -2,5 +2,5 @@ class test::ip_address( Stdlib::Compat::Ip_address $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/ipv4.pp b/spec/fixtures/test/manifests/ipv4.pp index 2e8022d54..38ad79a0b 100644 --- a/spec/fixtures/test/manifests/ipv4.pp +++ b/spec/fixtures/test/manifests/ipv4.pp @@ -2,5 +2,5 @@ class test::ipv4( Stdlib::Compat::Ipv4 $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/ipv6.pp b/spec/fixtures/test/manifests/ipv6.pp index 7912fd6f1..49ffeb55f 100644 --- a/spec/fixtures/test/manifests/ipv6.pp +++ b/spec/fixtures/test/manifests/ipv6.pp @@ -2,5 +2,5 @@ class test::ipv6( Stdlib::Compat::Ipv6 $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/numeric.pp b/spec/fixtures/test/manifests/numeric.pp index 2657ebc7b..0084660ee 100644 --- a/spec/fixtures/test/manifests/numeric.pp +++ b/spec/fixtures/test/manifests/numeric.pp @@ -3,6 +3,6 @@ Stdlib::Compat::Numeric $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/string.pp b/spec/fixtures/test/manifests/string.pp index 6508c70d7..2cd4e2ffb 100644 --- a/spec/fixtures/test/manifests/string.pp +++ b/spec/fixtures/test/manifests/string.pp @@ -3,6 +3,6 @@ Stdlib::Compat::String $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/unixpath.pp b/spec/fixtures/test/manifests/unixpath.pp index 93111091e..1e684e34c 100644 --- a/spec/fixtures/test/manifests/unixpath.pp +++ b/spec/fixtures/test/manifests/unixpath.pp @@ -2,5 +2,5 @@ class test::unixpath( Stdlib::Unixpath $value, ) { - notice("Success") + notice('Success') } diff --git a/spec/fixtures/test/manifests/windowspath.pp b/spec/fixtures/test/manifests/windowspath.pp index af93ed3f8..37c6e981b 100644 --- a/spec/fixtures/test/manifests/windowspath.pp +++ b/spec/fixtures/test/manifests/windowspath.pp @@ -2,5 +2,5 @@ class test::windowspath( Stdlib::Windowspath $value, ) { - notice("Success") + notice('Success') } diff --git a/types/compat/absolute_path.pp b/types/compat/absolute_path.pp index d11784e0d..60f9c861f 100644 --- a/types/compat/absolute_path.pp +++ b/types/compat/absolute_path.pp @@ -4,4 +4,4 @@ # slash = '[\\\\/]' # name = '[^\\\\/]+' # %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i, -type Stdlib::Compat::Absolute_path = Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]] +type Stdlib::Compat::Absolute_path = Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]] # lint:ignore:140chars diff --git a/types/compat/integer.pp b/types/compat/integer.pp index e5cadb619..047344d55 100644 --- a/types/compat/integer.pp +++ b/types/compat/integer.pp @@ -20,4 +20,4 @@ # > Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers. # # This allows you to find all places where a consumers of your code call it with unexpected values. -type Stdlib::Compat::Integer = Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]] +type Stdlib::Compat::Integer = Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]] # lint:ignore:140chars diff --git a/types/compat/ipv4.pp b/types/compat/ipv4.pp index a0ba0d6e1..87a4dc991 100644 --- a/types/compat/ipv4.pp +++ b/types/compat/ipv4.pp @@ -1,2 +1,2 @@ # Emulate the validate_ipv4_address and is_ipv4_address functions -type Stdlib::Compat::Ipv4 = Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/] +type Stdlib::Compat::Ipv4 = Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/] # lint:ignore:140chars diff --git a/types/compat/ipv6.pp b/types/compat/ipv6.pp index 8b82f1a5c..0a9677e91 100644 --- a/types/compat/ipv6.pp +++ b/types/compat/ipv6.pp @@ -1 +1 @@ -type Stdlib::Compat::Ipv6 = Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d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[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/] # lint:ignore:140chars diff --git a/types/compat/numeric.pp b/types/compat/numeric.pp index 5bfc3d3eb..3cf9c0d09 100644 --- a/types/compat/numeric.pp +++ b/types/compat/numeric.pp @@ -20,4 +20,4 @@ # > Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers. # # This allows you to find all places where a consumers of your code call it with unexpected values. -type Stdlib::Compat::Numeric = Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]] +type Stdlib::Compat::Numeric = Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]] # lint:ignore:140chars