Skip to content

Commit

Permalink
Merge pull request #5 from mackerelio/fix-lint
Browse files Browse the repository at this point in the history
use golangci-lint
  • Loading branch information
yseto authored Dec 29, 2022
2 parents 22155b0 + 42c4c27 commit 23ec83d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ on:
env:
DEBIAN_FRONTEND: noninteractive
jobs:
# TODO
# It's intended for code migration, so it's now a comment
# lint:
# strategy:
# matrix:
# os: [ubuntu-latest]
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v3
# - uses: golangci/golangci-lint-action@v3
# with:
# args: --timeout 2m
lint:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: golangci/golangci-lint-action@v3
with:
args: --timeout 2m
test:
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/go-sql-driver/mysql v1.7.0
github.com/mackerelio/go-mackerel-plugin v0.1.4
github.com/stretchr/testify v1.8.1
golang.org/x/text v0.3.7
)

require (
Expand All @@ -14,7 +15,6 @@ require (
github.com/mackerelio/golib v1.2.1 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
18 changes: 10 additions & 8 deletions lib/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"strconv"
"strings"

"golang.org/x/text/cases"
"golang.org/x/text/language"

mp "github.com/mackerelio/go-mackerel-plugin"
// MySQL Driver
"github.com/go-sql-driver/mysql"
Expand Down Expand Up @@ -47,12 +50,12 @@ func init() {
}

func (m *MySQLPlugin) defaultGraphdef() map[string]mp.Graphs {
labelPrefix := strings.Title(strings.Replace(m.MetricKeyPrefix(), "mysql", "MySQL", -1))
labelPrefix := cases.Title(language.Und, cases.NoLower).String(strings.Replace(m.MetricKeyPrefix(), "mysql", "MySQL", -1))

capacityMetrics := []mp.Metrics{
{Name: "PercentageOfConnections", Label: "Percentage Of Connections", Diff: false, Stacked: false},
}
if m.DisableInnoDB != true {
if !m.DisableInnoDB {
capacityMetrics = append(capacityMetrics, mp.Metrics{
Name: "PercentageOfBufferPool", Label: "Percentage Of Buffer Pool", Diff: false, Stacked: false,
})
Expand Down Expand Up @@ -191,7 +194,7 @@ func (m *MySQLPlugin) fetchVersion(db *sql.DB) (version [3]int, err error) {
version[2], _ = strconv.Atoi(xs[2])
}
}
break
break //nolint
}
if version[0] == 0 {
err = errors.New("failed to get mysql version")
Expand Down Expand Up @@ -371,7 +374,7 @@ func (m *MySQLPlugin) convertInnodbStats(stat map[string]float64) {

func (m *MySQLPlugin) calculateCapacity(stat map[string]float64) {
stat["PercentageOfConnections"] = 100.0 * stat["Threads_connected"] / stat["max_connections"]
if m.DisableInnoDB != true {
if !m.DisableInnoDB {
stat["PercentageOfBufferPool"] = 100.0 * stat["database_pages"] / stat["pool_size"]
}
}
Expand Down Expand Up @@ -415,7 +418,7 @@ func (m *MySQLPlugin) FetchMetrics() (map[string]float64, error) {
return nil, err
}

if m.DisableInnoDB != true {
if !m.DisableInnoDB {
m.convertInnodbStats(stat)
if !m.isAuroraReader {
err := m.fetchShowInnodbStatus(db, stat)
Expand Down Expand Up @@ -475,7 +478,7 @@ func (m *MySQLPlugin) GraphDefinition() map[string]mp.Graphs {
}

func (m *MySQLPlugin) addGraphdefWithInnoDBMetrics(graphdef map[string]mp.Graphs) map[string]mp.Graphs {
labelPrefix := strings.Title(strings.Replace(m.MetricKeyPrefix(), "mysql", "MySQL", -1))
labelPrefix := cases.Title(language.Und, cases.NoLower).String(strings.Replace(m.MetricKeyPrefix(), "mysql", "MySQL", -1))
graphdef["innodb_rows"] = mp.Graphs{
Label: labelPrefix + " innodb Rows",
Unit: "float",
Expand Down Expand Up @@ -666,8 +669,7 @@ func (m *MySQLPlugin) addGraphdefWithInnoDBMetrics(graphdef map[string]mp.Graphs
}

func (m *MySQLPlugin) addExtendedGraphdef(graphdef map[string]mp.Graphs) map[string]mp.Graphs {
//TODO
labelPrefix := strings.Title(strings.Replace(m.MetricKeyPrefix(), "mysql", "MySQL", -1))
labelPrefix := cases.Title(language.Und, cases.NoLower).String(strings.Replace(m.MetricKeyPrefix(), "mysql", "MySQL", -1))
graphdef["query_cache"] = mp.Graphs{
Label: labelPrefix + " query Cache",
Unit: "float",
Expand Down

0 comments on commit 23ec83d

Please sign in to comment.