Skip to content

Commit

Permalink
Merge pull request #22 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 1.5.1
  • Loading branch information
andyone committed Feb 2, 2016
2 parents 4ccdf09 + 0526ee6 commit 90c98d3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

#### v1.5.1

* `[knf]` Fixed bug in HasProp method which return true for unset properties

#### v1.5.0

* `[tmp]` Improved error handling
Expand Down
24 changes: 11 additions & 13 deletions knf/knf.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ func (c *Config) GetS(name string, defvals ...string) string {
return ""
}

val, ok := c.data[name]
val := c.data[name]

if !ok || val == "" {
if val == "" {
if len(defvals) == 0 {
return ""
}
Expand All @@ -294,9 +294,9 @@ func (c *Config) GetI(name string, defvals ...int) int {
return 0
}

val, ok := c.data[name]
val := c.data[name]

if !ok || val == "" {
if val == "" {
if len(defvals) == 0 {
return 0
}
Expand Down Expand Up @@ -330,9 +330,9 @@ func (c *Config) GetF(name string, defvals ...float64) float64 {
return 0.0
}

val, ok := c.data[name]
val := c.data[name]

if !ok || val == "" {
if val == "" {
if len(defvals) == 0 {
return 0.0
}
Expand All @@ -355,9 +355,9 @@ func (c *Config) GetB(name string, defvals ...bool) bool {
return false
}

val, ok := c.data[name]
val := c.data[name]

if !ok || val == "" {
if val == "" {
if len(defvals) == 0 {
return false
}
Expand All @@ -379,9 +379,9 @@ func (c *Config) GetM(name string, defvals ...os.FileMode) os.FileMode {
return 0
}

val, ok := c.data[name]
val := c.data[name]

if !ok || val == "" {
if val == "" {
if len(defvals) == 0 {
return 0
}
Expand Down Expand Up @@ -413,9 +413,7 @@ func (c *Config) HasProp(name string) bool {
return false
}

_, ok := c.data[name]

return ok
return c.data[name] != ""
}

// Sections return slice with section names
Expand Down
4 changes: 2 additions & 2 deletions knf/knf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ func (s *KNFSuite) TestCheckers(c *check.C) {
c.Assert(HasSection("strings"), check.Equals, false)

c.Assert(HasProp("string:test1"), check.Equals, true)
c.Assert(HasProp("string:test9"), check.Equals, false)
c.Assert(HasProp("strings:test9"), check.Equals, false)
c.Assert(HasProp("string:test6"), check.Equals, false)
c.Assert(HasProp("strings:test6"), check.Equals, false)
}

func (s *KNFSuite) TestFormating(c *check.C) {
Expand Down

0 comments on commit 90c98d3

Please sign in to comment.