Fix linting errors

This commit is contained in:
Vladimir Hodakov 2019-03-30 07:06:15 +04:00
parent 1fbeb6c063
commit 6be8ec6672
Signed by: Vladimir Hodakov
GPG Key ID: 673980B6882F82C6
4 changed files with 30 additions and 18 deletions

19
.golangci.yaml Normal file
View File

@ -0,0 +1,19 @@
run:
deadline: 5m
linters:
enable-all: true
disable:
- gochecknoglobals
- goimports
- gocritic
linters-settings:
lll:
line-length: 420
gocyclo:
min-complexity: 40
issues:
exclude-rules:
- path: "exported.go"
linters:
- dupl

View File

@ -16,9 +16,9 @@ func authorize() {
baseURL := "https://oauth.yandex.ru/authorize?response_type=code&client_id={{ client_id }}" baseURL := "https://oauth.yandex.ru/authorize?response_type=code&client_id={{ client_id }}"
baseURL += "&device_id={{ device_id }}&device_name={{ device_name }}&force_confirm=yes" baseURL += "&device_id={{ device_id }}&device_name={{ device_name }}&force_confirm=yes"
baseURL = strings.Replace(baseURL, "{{ client_id }}", YANDEX_APPID, 1) baseURL = strings.Replace(baseURL, "{{ client_id }}", YandexAppID, 1)
baseURL = strings.Replace(baseURL, "{{ device_id }}", c.Config.DeviceID, 1) baseURL = strings.Replace(baseURL, "{{ device_id }}", c.Config.DeviceID, 1)
baseURL = strings.Replace(baseURL, "{{ device_name }}", DEVICE_NAME, 1) baseURL = strings.Replace(baseURL, "{{ device_name }}", DefaultDeviceName, 1)
dlog.Info().Msg("Please open in your browser this URL and authorize the app. After getting the code restart the app with -authCode param (see -h for details).") dlog.Info().Msg("Please open in your browser this URL and authorize the app. After getting the code restart the app with -authCode param (see -h for details).")
dlog.Info().Msgf("Auth URL: %s", baseURL) dlog.Info().Msgf("Auth URL: %s", baseURL)
@ -29,9 +29,5 @@ func authorize() {
// checkAuth detects if we have authorized already // checkAuth detects if we have authorized already
func checkAuth() bool { func checkAuth() bool {
if c.Config.Token.AccessToken != "" { return c.Config.Token.AccessToken != ""
return true
}
return false
} }

View File

@ -9,10 +9,10 @@ import (
"gitlab.com/pztrn/flagger" "gitlab.com/pztrn/flagger"
) )
const YANDEX_APPID = "7d8a0561fdc44c05bb6695b464403f9c" const YandexAppID = "7d8a0561fdc44c05bb6695b464403f9c"
const YANDEX_APPPW = "56e12e4ed0d64738bf441a47f68c7146" const YandexAppPw = "56e12e4ed0d64738bf441a47f68c7146"
const DEVICE_NAME = "yapusher-cli" const DefaultDeviceName = "yapusher-cli"
const MAX_FILE_SIZE = 10 * 1024 * 1024 * 1024 // 10 gigabytes const MaxUploadSize = 10 * 1024 * 1024 * 1024 // 10 gigabytes
var ( var (
c *context.Context c *context.Context

View File

@ -14,9 +14,6 @@ import (
"strings" "strings"
) )
func reportFileProgress(r int64) {
}
func sendCode(code int) { func sendCode(code int) {
baseURL := "https://oauth.yandex.ru/token" baseURL := "https://oauth.yandex.ru/token"
@ -25,9 +22,9 @@ func sendCode(code int) {
form.Set("grant_type", "authorization_code") form.Set("grant_type", "authorization_code")
form.Set("code", strconv.Itoa(code)) form.Set("code", strconv.Itoa(code))
form.Set("device_id", c.Config.DeviceID) form.Set("device_id", c.Config.DeviceID)
form.Set("device_name", DEVICE_NAME) form.Set("device_name", DefaultDeviceName)
form.Set("client_id", YANDEX_APPID) form.Set("client_id", YandexAppID)
form.Set("client_secret", YANDEX_APPPW) form.Set("client_secret", YandexAppPw)
req, _ := http.NewRequest("POST", baseURL, strings.NewReader(form.Encode())) req, _ := http.NewRequest("POST", baseURL, strings.NewReader(form.Encode()))
req.Header.Add("Content-Type", "application/x-www-form-urlencoded") req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
@ -78,7 +75,7 @@ func uploadFile(uploadPath string, filePath string, overwriteFile bool) {
} }
} }
if fileInfo.Size() > (MAX_FILE_SIZE - 1) { if fileInfo.Size() > (MaxUploadSize - 1) {
dlog.Fatal().Msg("Requested file is too big") dlog.Fatal().Msg("Requested file is too big")
} }