Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update linter to use go vet #563

Merged
merged 11 commits into from
Feb 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,3 @@ plz-out/bin/src/please $PLZ_ARGS ${PLZ_COVER:-test} $EXCLUDES --exclude=e2e --lo
# finicky about some things due to running plz recursively and disabling the lock.
notice "Running end-to-end tests..."
plz-out/bin/src/please $PLZ_ARGS ${PLZ_COVER:-test} $EXCLUDES --include=e2e --log_file plz-out/log/test_build.log --log_file_level 4 $@

# Lint needs python3.
if hash python3 2>/dev/null ; then
# Don't run this in CI or any unusual workflows.
if [ $# -eq 0 ] ; then
plz lint
fi
fi
2 changes: 1 addition & 1 deletion src/cache/rpc_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ package cache

import (
"bytes"
"github.com/thought-machine/please/src/core"
"crypto/tls"
"crypto/x509"
"encoding/base64"
"fmt"
"github.com/thought-machine/please/src/core"
"io/ioutil"
"os"
"path"
Expand Down
2 changes: 1 addition & 1 deletion src/cache/rpc_cache_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
package cache

import (
"github.com/thought-machine/please/src/core"
"fmt"
"github.com/thought-machine/please/src/core"
)

func newRPCCache(config *core.Configuration) (*httpCache, error) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ type Configuration struct {
DefaultNamespace string `help:"Namespace passed to all cc_embed_binary rules when not overridden by the namespace argument to that rule.\nNot set by default, if you want to use those rules you'll need to set it or pass it explicitly to each one." var:"DEFAULT_NAMESPACE"`
PkgConfigPath string `help:"Custom PKG_CONFIG_PATH for pkg-config.\nBy default this is empty." var:"PKG_CONFIG_PATH"`
Coverage bool `help:"If true (the default), coverage will be available for C and C++ build rules.\nThis is still a little experimental but should work for GCC. Right now it does not work for Clang (it likely will in Clang 4.0 which will likely support --fprofile-dir) and so this can be useful to disable it.\nIt's also useful in some cases for CI systems etc if you'd prefer to avoid the overhead, since the tests have to be compiled with extra instrumentation and without optimisation." var:"CPP_COVERAGE"`
TestMain BuildLabel `help:"The build target to use for the default main for C++ test rules." example:"@pleasings//cc:unittest_main" var:"CC_TEST_MAIN"`
TestMain BuildLabel `help:"The build target to use for the default main for C++ test rules." example:"///pleasings//cc:unittest_main" var:"CC_TEST_MAIN"`
ClangModules bool `help:"Uses Clang-style arguments for compiling cc_module rules. If disabled gcc-style arguments will be used instead. Experimental, expected to be removed at some point once module compilation methods are more consistent." var:"CC_MODULES_CLANG"`
} `help:"Please has built-in support for compiling C and C++ code. We don't support every possible nuance of compilation for these languages, but aim to provide something fairly straightforward.\nTypically there is little problem compiling & linking against system libraries although Please has no insight into those libraries and when they change, so cannot rebuild targets appropriately.\n\nThe C and C++ rules are very similar and simply take a different set of tools and flags to facilitate side-by-side usage."`
Proto struct {
Expand Down
14 changes: 7 additions & 7 deletions src/ide/intellij/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

type libraryComponent struct {
XMLName xml.Name `xml:"component"`
Name string `xml:"name,attr"`
Library Library `xml:"library"`
Name string `xml:"name,attr"`
Library Library `xml:"library"`
}

// Content is a simple wrapper for a URL.
Expand All @@ -33,7 +33,7 @@ func newLibrary(graph *core.BuildGraph, target *core.BuildTarget) Library {
classes := []Content{}
javadocs := []Content{}
sources := []Content{}
for _, dep := range target.Sources {
for _, dep := range target.Sources {
label := dep.Label()
if label != nil {
depTarget := graph.TargetOrDie(*label)
Expand Down Expand Up @@ -65,9 +65,9 @@ func newLibrary(graph *core.BuildGraph, target *core.BuildTarget) Library {
}

library := Library{
Name: libraryName(target),
SourcePaths: sources,
ClassPaths: classes,
Name: libraryName(target),
SourcePaths: sources,
ClassPaths: classes,
JavadocPaths: javadocs,
}

Expand All @@ -76,7 +76,7 @@ func newLibrary(graph *core.BuildGraph, target *core.BuildTarget) Library {

func (library *Library) toXML(writer io.Writer) {
table := libraryComponent{
Name: "libraryTable",
Name: "libraryTable",
Library: *library,
}
contents, err := xml.MarshalIndent(table, "", " ")
Expand Down
2 changes: 1 addition & 1 deletion src/ide/intellij/library_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestLibraryToXml(t *testing.T) {
buf := &bytes.Buffer{}
library.toXML(buf)
assert.Equal(t,
"<component name=\"libraryTable\">\n"+
"<component name=\"libraryTable\">\n"+
" <library name=\"finagle-base-http\">\n"+
" <CLASSES>\n"+
" <root url=\"jar://$USER_HOME$/code/git.corp.tmachine.io/CORE/plz-out/gen/third_party/java/com/twitter/finagle-base-http.jar!/\"></root>\n"+
Expand Down
18 changes: 9 additions & 9 deletions src/ide/intellij/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (

// Module represents the IntelliJ concept of a module
type Module struct {
XMLName xml.Name `xml:"module"`
ModuleType string `xml:"type,attr"`
Version int `xml:"version,attr"`
Component ModuleComponent `xml:"component"`
XMLName xml.Name `xml:"module"`
ModuleType string `xml:"type,attr"`
Version int `xml:"version,attr"`
Component ModuleComponent `xml:"component"`
}

func newModule(graph *core.BuildGraph, target *core.BuildTarget) Module {
Expand All @@ -31,7 +31,7 @@ func newModule(graph *core.BuildGraph, target *core.BuildTarget) Module {
module := Module{
ModuleType: "WEB_MODULE",
Version: 4,
Component: component,
Component: component,
}

return module
Expand Down Expand Up @@ -135,7 +135,7 @@ func (module *Module) toXML(writer io.Writer) {
writer.Write([]byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"))

content, err := xml.MarshalIndent(module, "", " ")
if err == nil {
if err == nil {
writer.Write(content)
}
}
Expand All @@ -153,7 +153,7 @@ func newModuleComponent(target *core.BuildTarget) ModuleComponent {
orderEntries := []OrderEntry{}

return ModuleComponent{
Name: "NewModuleRootManager",
Name: "NewModuleRootManager",
InheritCompilerOutput: true,
Content: newModuleContent(target),
OrderEntries: orderEntries,
Expand Down Expand Up @@ -231,7 +231,7 @@ func newLibraryEntry(name, level string) OrderEntry {
Type: "library",
LibraryName: &name,
LibraryLevel: &level,
Exported: &exported,
Exported: &exported,
}
}

Expand All @@ -240,7 +240,7 @@ func newModuleEntry(name string) OrderEntry {
return OrderEntry{
Type: "module",
ModuleName: &name,
Exported: &exported,
Exported: &exported,
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/ide/intellij/project.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package intellij

import (
"github.com/thought-machine/please/src/core"
"encoding/xml"
"fmt"
"github.com/thought-machine/please/src/core"
"io"
)

Expand All @@ -25,7 +25,7 @@ func (misc *Misc) toXML(w io.Writer) {
w.Write([]byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"))
content, err := xml.MarshalIndent(misc, "", " ")

if err == nil {
if err == nil {
w.Write(content)
}
}
Expand Down Expand Up @@ -72,8 +72,8 @@ func newMiscOutput() MiscOutput {

// Modules are the main structure that tells IntelliJ where to find all the modules it knows about.
type Modules struct {
XMLName xml.Name `xml:"project"`
Version int `xml:"version,attr"`
XMLName xml.Name `xml:"project"`
Version int `xml:"version,attr"`
Component ModulesComponent `xml:"component"`
}

Expand All @@ -88,15 +88,15 @@ func (modules *Modules) toXML(w io.Writer) {
w.Write([]byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"))
content, err := xml.MarshalIndent(modules, "", " ")

if err == nil {
if err == nil {
w.Write(content)
}
}

// ModulesComponent represents all modules in the workspace.
type ModulesComponent struct {
XMLName xml.Name `xml:"component"`
Name string `xml:"name,attr"`
XMLName xml.Name `xml:"component"`
Name string `xml:"name,attr"`
Modules []ModulesModule `xml:"modules>module"`
}

Expand All @@ -122,7 +122,7 @@ type ModulesModule struct {
func newModulesModule(label core.BuildLabel) ModulesModule {
filePath := "$PROJECT_DIR$/" + label.PackageDir() + "/" + fmt.Sprintf("%s.iml", moduleName(label))
return ModulesModule{
FileURL: "file://"+filePath,
FileURL: "file://" + filePath,
FilePath: filePath,
}
}
1 change: 1 addition & 0 deletions src/output/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_library(
name = "output",
srcs = [
"print.go",
"print_bootstrap.go",
"trace.go",
":ansi_replacements",
],
Expand Down
4 changes: 0 additions & 4 deletions src/output/shell_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@ import (
"sync"
"time"

"gopkg.in/op/go-logging.v1"

"github.com/thought-machine/please/src/build"
"github.com/thought-machine/please/src/cli"
"github.com/thought-machine/please/src/core"
"github.com/thought-machine/please/src/test"
)

var log = logging.MustGetLogger("output")

// durationGranularity is the granularity that we build durations at.
const durationGranularity = 10 * time.Millisecond
const testDurationGranularity = time.Millisecond
Expand Down
14 changes: 10 additions & 4 deletions src/output/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@

package output

import "encoding/json"
import "fmt"
import "os"
import (
"encoding/json"
"fmt"
"os"

import "github.com/thought-machine/please/src/core"
"gopkg.in/op/go-logging.v1"

"github.com/thought-machine/please/src/core"
)

var log = logging.MustGetLogger("output")

var traces = make([]traceEntry, 0, 1000)

Expand Down
Loading