From 04d4881512b1e99a2045c5fff5760607bc157352 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser <muesli@gmail.com> Date: Fri, 19 Jul 2019 12:47:21 +0200 Subject: [PATCH] Simplified boolean comparisons Just a bit easier to read, in my opinion. --- runtime/ci/evaluator.go | 5 +---- ui/details_controller.go | 5 +---- ui/filetree_controller.go | 5 +---- ui/filetree_viewmodel.go | 5 +---- ui/layer_controller.go | 5 +---- ui/status_controller.go | 5 +---- 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/runtime/ci/evaluator.go b/runtime/ci/evaluator.go index ddc598b..8086779 100644 --- a/runtime/ci/evaluator.go +++ b/runtime/ci/evaluator.go @@ -42,10 +42,7 @@ func (ci *Evaluator) LoadConfig(configFile string) error { func (ci *Evaluator) isRuleEnabled(rule Rule) bool { value := ci.Config.GetString(rule.Key()) - if value == "disabled" { - return false - } - return true + return value != "disabled" } func (ci *Evaluator) Evaluate(analysis *image.AnalysisResult) bool { diff --git a/ui/details_controller.go b/ui/details_controller.go index 68dd5df..0329ac5 100644 --- a/ui/details_controller.go +++ b/ui/details_controller.go @@ -62,10 +62,7 @@ func (controller *DetailsController) Setup(v *gocui.View, header *gocui.View) er // IsVisible indicates if the details view pane is currently initialized. func (controller *DetailsController) IsVisible() bool { - if controller == nil { - return false - } - return true + return controller != nil } // CursorDown moves the cursor down in the details pane (currently indicates nothing). diff --git a/ui/filetree_controller.go b/ui/filetree_controller.go index cc53cc7..991266e 100644 --- a/ui/filetree_controller.go +++ b/ui/filetree_controller.go @@ -182,10 +182,7 @@ func (controller *FileTreeController) Setup(v *gocui.View, header *gocui.View) e // IsVisible indicates if the file tree view pane is currently initialized func (controller *FileTreeController) IsVisible() bool { - if controller == nil { - return false - } - return true + return controller != nil } // resetCursor moves the cursor back to the top of the buffer and translates to the top of the buffer. diff --git a/ui/filetree_viewmodel.go b/ui/filetree_viewmodel.go index 7394070..5673a3d 100644 --- a/ui/filetree_viewmodel.go +++ b/ui/filetree_viewmodel.go @@ -86,10 +86,7 @@ func (vm *FileTreeViewModel) bufferIndexUpperBound() int { // IsVisible indicates if the file tree view pane is currently initialized func (vm *FileTreeViewModel) IsVisible() bool { - if vm == nil { - return false - } - return true + return vm != nil } // resetCursor moves the cursor back to the top of the buffer and translates to the top of the buffer. diff --git a/ui/layer_controller.go b/ui/layer_controller.go index 0210544..c0674b4 100644 --- a/ui/layer_controller.go +++ b/ui/layer_controller.go @@ -135,10 +135,7 @@ func (controller *LayerController) height() uint { // IsVisible indicates if the layer view pane is currently initialized. func (controller *LayerController) IsVisible() bool { - if controller == nil { - return false - } - return true + return controller != nil } // PageDown moves to next page putting the cursor on top diff --git a/ui/status_controller.go b/ui/status_controller.go index da4f660..1620780 100644 --- a/ui/status_controller.go +++ b/ui/status_controller.go @@ -40,10 +40,7 @@ func (controller *StatusController) Setup(v *gocui.View, header *gocui.View) err // IsVisible indicates if the status view pane is currently initialized. func (controller *StatusController) IsVisible() bool { - if controller == nil { - return false - } - return true + return controller != nil } // CursorDown moves the cursor down in the details pane (currently indicates nothing).