diff --git a/vlib/semver/compare.v b/vlib/semver/compare.v index 07bf6fc9a5..991994783a 100644 --- a/vlib/semver/compare.v +++ b/vlib/semver/compare.v @@ -3,9 +3,7 @@ module semver // * Private functions. [inline] fn version_satisfies(ver Version, input string) bool { - range := parse_range(input) or { - return false - } + range := parse_range(input) or { return false } return range.satisfies(ver) } diff --git a/vlib/semver/parse.v b/vlib/semver/parse.v index 292c0d50ca..1b119037c6 100644 --- a/vlib/semver/parse.v +++ b/vlib/semver/parse.v @@ -21,16 +21,12 @@ fn parse(input string) RawVersion { mut raw_version := input mut prerelease := '' mut metadata := '' - plus_idx := raw_version.last_index('+') or { - -1 - } + plus_idx := raw_version.last_index('+') or { -1 } if plus_idx > 0 { metadata = raw_version[(plus_idx + 1)..] raw_version = raw_version[0..plus_idx] } - hyphen_idx := raw_version.index('-') or { - -1 - } + hyphen_idx := raw_version.index('-') or { -1 } if hyphen_idx > 0 { prerelease = raw_version[(hyphen_idx + 1)..] raw_version = raw_version[0..hyphen_idx] diff --git a/vlib/semver/range.v b/vlib/semver/range.v index 7e6c55810c..60531c0a24 100644 --- a/vlib/semver/range.v +++ b/vlib/semver/range.v @@ -61,14 +61,10 @@ fn parse_range(input string) ?Range { mut comparator_sets := []ComparatorSet{} for raw_comp_set in raw_comparator_sets { if can_expand(raw_comp_set) { - s := expand_comparator_set(raw_comp_set) or { - return error(err) - } + s := expand_comparator_set(raw_comp_set) or { return error(err) } comparator_sets << s } else { - s := parse_comparator_set(raw_comp_set) or { - return error(err) - } + s := parse_comparator_set(raw_comp_set) or { return error(err) } comparator_sets << s } } @@ -82,9 +78,7 @@ fn parse_comparator_set(input string) ?ComparatorSet { } mut comparators := []Comparator{} for raw_comp in raw_comparators { - c := parse_comparator(raw_comp) or { - return error('Invalid comparator: $raw_comp') - } + c := parse_comparator(raw_comp) or { return error('Invalid comparator: $raw_comp') } comparators << c } return ComparatorSet{comparators} @@ -110,9 +104,7 @@ fn parse_comparator(input string) ?Comparator { } else { raw_version = input } - version := coerce_version(raw_version) or { - return none - } + version := coerce_version(raw_version) or { return none } return Comparator{version, op} } @@ -162,9 +154,7 @@ fn expand_comparator_set(input string) ?ComparatorSet { } fn expand_tilda(raw_version string) ?ComparatorSet { - min_ver := coerce_version(raw_version) or { - return none - } + min_ver := coerce_version(raw_version) or { return none } mut max_ver := min_ver if min_ver.minor == 0 && min_ver.patch == 0 { max_ver = min_ver.increment(.major) @@ -175,9 +165,7 @@ fn expand_tilda(raw_version string) ?ComparatorSet { } fn expand_caret(raw_version string) ?ComparatorSet { - min_ver := coerce_version(raw_version) or { - return none - } + min_ver := coerce_version(raw_version) or { return none } mut max_ver := min_ver if min_ver.major == 0 { max_ver = min_ver.increment(.minor) @@ -192,16 +180,12 @@ fn expand_hyphen(raw_range string) ?ComparatorSet { if raw_versions.len != 2 { return none } - min_ver := coerce_version(raw_versions[0]) or { - return none - } + min_ver := coerce_version(raw_versions[0]) or { return none } raw_max_ver := parse(raw_versions[1]) if raw_max_ver.is_missing(ver_major) { return none } - mut max_ver := raw_max_ver.coerce() or { - return none - } + mut max_ver := raw_max_ver.coerce() or { return none } if raw_max_ver.is_missing(ver_minor) { max_ver = max_ver.increment(.minor) return make_comparator_set_ge_lt(min_ver, max_ver) @@ -210,9 +194,7 @@ fn expand_hyphen(raw_range string) ?ComparatorSet { } fn expand_xrange(raw_range string) ?ComparatorSet { - min_ver := parse_xrange(raw_range) or { - return none - } + min_ver := parse_xrange(raw_range) or { return none } if min_ver.major == 0 { comparators := [ Comparator{min_ver, Operator.ge}, diff --git a/vlib/semver/semver.v b/vlib/semver/semver.v index 903c21374c..fe872921d5 100644 --- a/vlib/semver/semver.v +++ b/vlib/semver/semver.v @@ -26,9 +26,7 @@ pub fn from(input string) ?Version { return error('Empty input') } raw_version := parse(input) - version := raw_version.validate() or { - return error('Invalid version format') - } + version := raw_version.validate() or { return error('Invalid version format') } return version } @@ -71,9 +69,7 @@ pub fn (v1 Version) le(v2 Version) bool { // * Utilites. pub fn coerce(input string) ?Version { - ver := coerce_version(input) or { - return error('Invalid version: $input') - } + ver := coerce_version(input) or { return error('Invalid version: $input') } return ver } diff --git a/vlib/semver/util.v b/vlib/semver/util.v index 3674844541..5e9c02672d 100644 --- a/vlib/semver/util.v +++ b/vlib/semver/util.v @@ -10,9 +10,7 @@ fn is_version_valid(input string) bool { [inline] fn coerce_version(input string) ?Version { raw_ver := parse(input) - ver := raw_ver.coerce() or { - return error('Invalid version: $input') - } + ver := raw_ver.coerce() or { return error('Invalid version: $input') } return ver }