Applied suggested linter changes

This commit is contained in:
Eduard Urbach 2018-04-26 01:14:23 +02:00
parent a45c39a916
commit e90873b64f
13 changed files with 42 additions and 79 deletions

View File

@ -1,6 +1,7 @@
package auth
import (
"context"
"encoding/json"
"errors"
"io/ioutil"
@ -57,14 +58,14 @@ func InstallFacebookAuth(app *aero.Application) {
}
// Handle the exchange code to initiate a transport
token, err := config.Exchange(oauth2.NoContext, ctx.Query("code"))
token, err := config.Exchange(context.Background(), ctx.Query("code"))
if err != nil {
return ctx.Error(http.StatusBadRequest, "Could not obtain OAuth token", err)
}
// Construct the OAuth client
client := config.Client(oauth2.NoContext, token)
client := config.Client(context.Background(), token)
// Fetch user data from Facebook
resp, err := client.Get("https://graph.facebook.com/me?fields=email,first_name,last_name,gender")

View File

@ -1,6 +1,7 @@
package auth
import (
"context"
"encoding/json"
"errors"
"io/ioutil"
@ -63,14 +64,14 @@ func InstallGoogleAuth(app *aero.Application) {
}
// Handle the exchange code to initiate a transport
token, err := config.Exchange(oauth2.NoContext, ctx.Query("code"))
token, err := config.Exchange(context.Background(), ctx.Query("code"))
if err != nil {
return ctx.Error(http.StatusBadRequest, "Could not obtain OAuth token", err)
}
// Construct the OAuth client
client := config.Client(oauth2.NoContext, token)
client := config.Client(context.Background(), token)
// Fetch user data from Google
resp, err := client.Get("https://www.googleapis.com/oauth2/v3/userinfo")

View File

@ -49,6 +49,6 @@ func main() {
// Wait for a CTRL-C
log.Printf("Tsundere is ready. Press CTRL-C to exit.")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-sc
}

View File

@ -101,7 +101,7 @@ func main() {
}
character.Description = strings.Join(finalLines, "\n\n")
character.Description = strings.Trim(character.Description, "\n\n")
character.Description = strings.Trim(character.Description, "\n")
character.Save()
// Save Kitsu character in Kitsu DB

View File

@ -1,7 +1,6 @@
package main
import (
"encoding/json"
"errors"
"fmt"
"os"
@ -47,13 +46,13 @@ func main() {
func readFile(name string) error {
file, err := os.Open(name)
defer file.Close()
if err != nil {
fmt.Println(err)
return err
}
defer file.Close()
anime, characters, err := malparser.ParseAnime(file)
if err != nil {
@ -95,9 +94,3 @@ func readFile(name string) error {
arn.MAL.Set("Anime", anime.ID, anime)
return nil
}
// prettyPrint prints the object as indented JSON data on the console.
func prettyPrint(obj interface{}) {
pretty, _ := json.MarshalIndent(obj, "", "\t")
fmt.Println(string(pretty))
}

View File

@ -45,17 +45,3 @@ func Get(ctx *aero.Context) string {
return ctx.HTML(components.Admin(user, platform, family, platformVersion, kernelVersion))
}
func average(floatSlice []float64) float64 {
if len(floatSlice) == 0 {
return 0
}
var sum float64
for _, value := range floatSlice {
sum += value
}
return sum / float64(len(floatSlice))
}

View File

@ -5,8 +5,6 @@ import (
"github.com/animenotifier/arn"
)
const maxEntries = 70
// Links shows soundtracks without links.
func Links(ctx *aero.Context) string {
return editorList(

View File

@ -7,8 +7,6 @@ import (
"github.com/animenotifier/notify.moe/utils"
)
const maxPosts = 5
// Get user profile page.
func Get(ctx *aero.Context) string {
nick := ctx.Get("nick")

View File

@ -19,11 +19,7 @@ func Active(ctx *aero.Context) string {
sort.Slice(users, func(i, j int) bool {
if users[i].HasAvatar() != users[j].HasAvatar() {
if users[i].HasAvatar() {
return true
}
return false
return users[i].HasAvatar()
}
followersA := followCount[users[i].ID]
@ -101,11 +97,7 @@ func ActiveNoAvatar(ctx *aero.Context) string {
sort.Slice(users, func(i, j int) bool {
if users[i].HasAvatar() != users[j].HasAvatar() {
if users[i].HasAvatar() {
return true
}
return false
return users[i].HasAvatar()
}
followersA := followCount[users[i].ID]

View File

@ -39,7 +39,7 @@ func main() {
modified = true
}
if modified == true {
if modified {
anime.Episodes().Save()
}
}

View File

@ -35,8 +35,6 @@ func main() {
png.Encode(f, improved)
}
const max = float64(65535)
// Pixel ...
type Pixel struct {
X int
@ -228,42 +226,42 @@ func ImproveQuality(img image.Image) *image.NRGBA {
offset++
}
// Determine surrounding area
surroundingAreaIndex := -1
bestScore := 0
// // Determine surrounding area
// surroundingAreaIndex := -1
// bestScore := 0
for checkIndex, score := range areaSurroundedBy {
if score > bestScore && checkIndex != areaIndex {
bestScore = score
surroundingAreaIndex = checkIndex
}
}
// for checkIndex, score := range areaSurroundedBy {
// if score > bestScore && checkIndex != areaIndex {
// bestScore = score
// surroundingAreaIndex = checkIndex
// }
// }
surroundingArea := areas[surroundingAreaIndex]
// surroundingArea := areas[surroundingAreaIndex]
if areaIndex != surroundingAreaIndex && len(surroundingArea.Pixels) > len(area.Pixels)*2 {
// const surroundTolerance = 5000
// if areaIndex != surroundingAreaIndex && len(surroundingArea.Pixels) > len(area.Pixels)*2 {
// // const surroundTolerance = 5000
// r1, g1, b1, a1 := area.AverageColor().RGBA()
// r2, g2, b2, a2 := surroundingArea.AverageColor().RGBA()
// // r1, g1, b1, a1 := area.AverageColor().RGBA()
// // r2, g2, b2, a2 := surroundingArea.AverageColor().RGBA()
// if diffAbs(r1, r2) < surroundTolerance && diffAbs(g1, g2) < surroundTolerance && diffAbs(b1, b2) < surroundTolerance && diffAbs(a1, a2) < surroundTolerance {
// // fmt.Println(areaIndex, "surrounded by", surroundingAreaIndex, "|", len(area.Pixels), len(surroundingArea.Pixels))
// // if diffAbs(r1, r2) < surroundTolerance && diffAbs(g1, g2) < surroundTolerance && diffAbs(b1, b2) < surroundTolerance && diffAbs(a1, a2) < surroundTolerance {
// // // fmt.Println(areaIndex, "surrounded by", surroundingAreaIndex, "|", len(area.Pixels), len(surroundingArea.Pixels))
// // Add pixels to surrounding area
// for _, pixel := range area.Pixels {
// r, g, b, a := img.At(pixel.X, pixel.Y).RGBA()
// surroundingArea.Add(pixel.X, pixel.Y, r, g, b, a)
// }
// // // Add pixels to surrounding area
// // for _, pixel := range area.Pixels {
// // r, g, b, a := img.At(pixel.X, pixel.Y).RGBA()
// // surroundingArea.Add(pixel.X, pixel.Y, r, g, b, a)
// // }
// // Remove this area
// area.Pixels = nil
// area.totalR = 0
// area.totalG = 0
// area.totalB = 0
// area.totalA = 0
// }
}
// // // Remove this area
// // area.Pixels = nil
// // area.totalR = 0
// // area.totalG = 0
// // area.totalB = 0
// // area.totalA = 0
// // }
// }
}
fmt.Println(noiseCount, "noise pixels")

View File

@ -28,10 +28,7 @@ func main() {
}
externalID := mapping.Attributes.ExternalID
if strings.HasPrefix(externalID, "anime/") {
externalID = externalID[len("anime/"):]
}
externalID = strings.TrimPrefix(externalID, "anime/")
anime := finder.GetAnime(mapping.Relationships.Item.Data.ID)

View File

@ -22,7 +22,6 @@ var ticker = time.NewTicker(50 * time.Millisecond)
// Shell parameters
var from int
var to int
var useCache bool
// Shell flags
func init() {