Skip to content

Commit

Permalink
Merge pull request #10 from konart/add-golangci-lint
Browse files Browse the repository at this point in the history
[WIP]:Add golangci lint
  • Loading branch information
jorgerojas26 authored Jan 11, 2024
2 parents f9442bb + 2049cae commit 62f54de
Show file tree
Hide file tree
Showing 20 changed files with 131 additions and 48 deletions.
80 changes: 80 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
linters-settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gci:
sections:
- standard
- default
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- commentedOutCode
gocyclo:
min-complexity: 15
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
govet:
check-shadowing: true
lll:
line-length: 140
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
# require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- gci
- bodyclose
- dogsled
- dupl
- errcheck
- exhaustive
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- nakedret
- noctx
- nolintlint
- rowserrcheck
- exportloopref
- staticcheck
- revive
- typecheck
- unconvert
- unparam
- unused
- whitespace
- wsl
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (form *ConnectionForm) inputCapture(connectionPages *models.ConnectionPages
func (form *ConnectionForm) testConnection(connectionString string) {
form.StatusText.SetText("Connecting...").SetTextStyle(tcell.StyleDefault.Foreground(tcell.ColorKhaki.TrueColor()))

db := drivers.MySql{}
db := drivers.MySQL{}
db.SetConnectionString(connectionString)

err := db.TestConnection()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (cs *ConnectionSelection) connect(connectionUrl string) {
cs.StatusText.SetText("Connecting...").SetTextStyle(tcell.StyleDefault.Foreground(app.ActiveTextColor))
App.Draw()

newDbDriver := drivers.MySql{}
newDbDriver := drivers.MySQL{}
newDbDriver.SetConnectionString(connectionUrl)

err := newDbDriver.Connect()
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions components/Home.go → components/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ type Home struct {
TabbedPane *TabbedPane
LeftWrapper *tview.Flex
RightWrapper *tview.Flex
DBDriver drivers.MySql
DBDriver drivers.MySQL
FocusedWrapper string
ListOfDbChanges []models.DbDmlChange
ListOfDbInserts []models.DbInsert
}

func NewHomePage(name string, dbdriver drivers.MySql) *Home {
func NewHomePage(name string, dbdriver drivers.MySQL) *Home {
tree := NewTree(&dbdriver)
tabbedPane := NewTabbedPane()
leftWrapper := tview.NewFlex()
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 13 additions & 13 deletions components/ResultsTable.go → components/resultsTable.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type ResultsTable struct {
EditorPages *tview.Pages
ResultsInfo *tview.TextView
Tree *Tree
DBDriver *drivers.MySql
DBDriver *drivers.MySQL
}

var (
Expand All @@ -55,7 +55,7 @@ var (
DeleteColor = tcell.ColorRed
)

func NewResultsTable(listOfDbChanges *[]models.DbDmlChange, listOfDbInserts *[]models.DbInsert, tree *Tree, dbdriver *drivers.MySql) *ResultsTable {
func NewResultsTable(listOfDbChanges *[]models.DbDmlChange, listOfDbInserts *[]models.DbInsert, tree *Tree, dbdriver *drivers.MySQL) *ResultsTable {
state := &ResultsTableState{
records: [][]string{},
columns: [][]string{},
Expand Down Expand Up @@ -201,7 +201,7 @@ func (table *ResultsTable) AddInsertedRows() {
for j, cell := range row {
tableCell := tview.NewTableCell(cell)
tableCell.SetExpansion(1)
tableCell.SetReference(inserts[i].RowId)
tableCell.SetReference(inserts[i].RowID)

tableCell.SetTextColor(app.FocusTextColor)
tableCell.SetBackgroundColor(InsertColor)
Expand Down Expand Up @@ -397,7 +397,7 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event
for i, insertedRow := range *table.state.listOfDbInserts {
cellReference := table.GetCell(selectedRowIndex, 0).GetReference()

if cellReference != nil && insertedRow.RowId.String() == cellReference.(uuid.UUID).String() {
if cellReference != nil && insertedRow.RowID.String() == cellReference.(uuid.UUID).String() {
isAnInsertedRow = true
indexOfInsertedRow = i
}
Expand Down Expand Up @@ -447,7 +447,7 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event
Table: table.GetDBReference(),
Columns: table.GetRecords()[0],
Values: newRow,
RowId: newRowUuid,
RowID: newRowUuid,
Option: 1,
}

Expand Down Expand Up @@ -958,19 +958,19 @@ func (table *ResultsTable) StartEditingCell(row int, col int, callback func(newV
App.SetFocus(inputField)
}

func (table *ResultsTable) CheckIfRowIsInserted(rowId uuid.UUID) bool {
func (table *ResultsTable) CheckIfRowIsInserted(rowID uuid.UUID) bool {
for _, insertedRow := range *table.state.listOfDbInserts {
if insertedRow.RowId == rowId {
if insertedRow.RowID == rowID {
return true
}
}

return false
}

func (table *ResultsTable) MutateInsertedRowCell(rowId uuid.UUID, colIndex int, newValue string) {
func (table *ResultsTable) MutateInsertedRowCell(rowID uuid.UUID, colIndex int, newValue string) {
for i, insertedRow := range *table.state.listOfDbInserts {
if insertedRow.RowId == rowId {
if insertedRow.RowID == rowID {
(*table.state.listOfDbInserts)[i].Values[colIndex] = newValue
}
}
Expand All @@ -992,13 +992,13 @@ func (table *ResultsTable) AppendNewChange(changeType string, tableName string,
}

if !isInsertedRow {
selectedRowId := table.GetRecords()[rowIndex][0]
selectedRowID := table.GetRecords()[rowIndex][0]

alreadyExists := false
indexOfChange := -1

for i, change := range *table.state.listOfDbChanges {
if change.RowId == selectedRowId && change.Column == table.GetColumnNameByIndex(colIndex) {
if change.RowID == selectedRowID && change.Column == table.GetColumnNameByIndex(colIndex) {
alreadyExists = true
indexOfChange = i
}
Expand Down Expand Up @@ -1038,7 +1038,7 @@ func (table *ResultsTable) AppendNewChange(changeType string, tableName string,
Table: tableName,
Column: columnName,
Value: value,
RowId: selectedRowId,
RowID: selectedRowID,
Option: 1,
}

Expand Down Expand Up @@ -1078,7 +1078,7 @@ func (table *ResultsTable) AppendNewChange(changeType string, tableName string,
Table: tableName,
Column: "",
Value: "",
RowId: selectedRowId,
RowID: selectedRowID,
Option: 1,
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions components/Tree.go → components/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ type TreeState struct {
type Tree struct {
*tview.TreeView
state *TreeState
DBDriver *drivers.MySql
DBDriver *drivers.MySQL
subscribers []chan models.StateChange
}

func NewTree(dbdriver *drivers.MySql) *Tree {
func NewTree(dbdriver *drivers.MySQL) *Tree {
state := &TreeState{
selectedDatabase: "",
selectedTable: "",
Expand Down
Loading

0 comments on commit 62f54de

Please sign in to comment.