Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

Check for redundant if err != nil constructs. #319

Merged
merged 2 commits into from
Sep 18, 2017
Merged

Conversation

abbot
Copy link
Contributor

@abbot abbot commented Aug 21, 2017

Detect and complain about constructs like:

if err := foo(); err != nil {
  return err
}
return nil

This is issue #312

Detect and complain about constructs like:

if err := foo(); err != nil {
  return err
}
return nil

(Issue golang#312)
Also don't emit lint errors if there are any comments explaining the
construct (between if and return statements).
@dsnet dsnet merged commit e5d664e into golang:master Sep 18, 2017
philipnrmn added a commit to mesosphere-backup/dcos-metrics that referenced this pull request Sep 19, 2017
In scripts/test.sh we naively run go get to update golint. A new rule
has just been added to golint (golang/lint#319)
and I don't want to complicate my current PR (#118).

I will revert this commit, fix any outstanding nil-returns and consider
pinning golint in a future PR.
philipnrmn added a commit to mesosphere-backup/dcos-metrics that referenced this pull request Sep 19, 2017
* Export TaskInfo from the mesos agent collector

We will reference TaskInfo in a map of container IDs to task info in a
later commit.

* Add a struct for container->task relationships

ContainerTaskRels has a single member, a map of container IDs to
TaskInfo references. It has a getter and a setter for easy access
threadsafe access to the relationship map, and an update method which
populates it from agentState.

* Return task_id and task_name in /app output

The new ContainerTaskRels argument providers access to the task metadata
for each container.

* Add tests for extracting a record with task data

We add a new mock object with appropriate metadata and supply it to
avroRecord.extract(), checking that the task IDs in the
ContainerTaskRels are the same ones that correspond to the container
ID.

* Add tests for executor ID and framework ID

This is orthogonal to the intent of this PR, however it's a small change
and seemed like a quick win.

* Refer to ContainerTaskRels in Framework collector

This reference can be provided to the extract method from the framework
collector.

* Pass ref to ContainerTaskRels into transform

* Update task mapping from agent collector

We update the task mapping after every new fetch from agent state.

* Pass reference to mapping into framework collector

Now the framework collector has access to the ContainerTaskRels object
which belongs to the mesos agent collector.

* Clarify arg name

* Defer unlock for consistency

* Temporarily skip golint in build

In scripts/test.sh we naively run go get to update golint. A new rule
has just been added to golint (golang/lint#319)
and I don't want to complicate my current PR (#118).

I will revert this commit, fix any outstanding nil-returns and consider
pinning golint in a future PR.

* Create new TaskInfo object to avoid memory issues

* Create ContainerTaskRels in dcos-metrics.go

Rather than initiating ContainerTaskRels in the framework collector, we
now initiate it in dcos-metrics.go and pass a reference into each
collector instead.

* Initiate ContainerTaskRels with a utility method

* Remove unnecessary nil check
philipnrmn added a commit to mesosphere-backup/dcos-metrics that referenced this pull request Sep 19, 2017
* Export TaskInfo from the mesos agent collector

We will reference TaskInfo in a map of container IDs to task info in a
later commit.

* Add a struct for container->task relationships

ContainerTaskRels has a single member, a map of container IDs to
TaskInfo references. It has a getter and a setter for easy access
threadsafe access to the relationship map, and an update method which
populates it from agentState.

* Return task_id and task_name in /app output

The new ContainerTaskRels argument providers access to the task metadata
for each container.

* Add tests for extracting a record with task data

We add a new mock object with appropriate metadata and supply it to
avroRecord.extract(), checking that the task IDs in the
ContainerTaskRels are the same ones that correspond to the container
ID.

* Add tests for executor ID and framework ID

This is orthogonal to the intent of this PR, however it's a small change
and seemed like a quick win.

* Refer to ContainerTaskRels in Framework collector

This reference can be provided to the extract method from the framework
collector.

* Pass ref to ContainerTaskRels into transform

* Update task mapping from agent collector

We update the task mapping after every new fetch from agent state.

* Pass reference to mapping into framework collector

Now the framework collector has access to the ContainerTaskRels object
which belongs to the mesos agent collector.

* Clarify arg name

* Defer unlock for consistency

* Temporarily skip golint in build

In scripts/test.sh we naively run go get to update golint. A new rule
has just been added to golint (golang/lint#319)
and I don't want to complicate my current PR (#118).

I will revert this commit, fix any outstanding nil-returns and consider
pinning golint in a future PR.

* Create new TaskInfo object to avoid memory issues

* Create ContainerTaskRels in dcos-metrics.go

Rather than initiating ContainerTaskRels in the framework collector, we
now initiate it in dcos-metrics.go and pass a reference into each
collector instead.

* Initiate ContainerTaskRels with a utility method

* Remove unnecessary nil check
philipnrmn added a commit to mesosphere-backup/dcos-metrics that referenced this pull request Sep 19, 2017
* Export TaskInfo from the mesos agent collector

We will reference TaskInfo in a map of container IDs to task info in a
later commit.

* Add a struct for container->task relationships

ContainerTaskRels has a single member, a map of container IDs to
TaskInfo references. It has a getter and a setter for easy access
threadsafe access to the relationship map, and an update method which
populates it from agentState.

* Return task_id and task_name in /app output

The new ContainerTaskRels argument providers access to the task metadata
for each container.

* Add tests for extracting a record with task data

We add a new mock object with appropriate metadata and supply it to
avroRecord.extract(), checking that the task IDs in the
ContainerTaskRels are the same ones that correspond to the container
ID.

* Add tests for executor ID and framework ID

This is orthogonal to the intent of this PR, however it's a small change
and seemed like a quick win.

* Refer to ContainerTaskRels in Framework collector

This reference can be provided to the extract method from the framework
collector.

* Pass ref to ContainerTaskRels into transform

* Update task mapping from agent collector

We update the task mapping after every new fetch from agent state.

* Pass reference to mapping into framework collector

Now the framework collector has access to the ContainerTaskRels object
which belongs to the mesos agent collector.

* Clarify arg name

* Defer unlock for consistency

* Temporarily skip golint in build

In scripts/test.sh we naively run go get to update golint. A new rule
has just been added to golint (golang/lint#319)
and I don't want to complicate my current PR (#118).

I will revert this commit, fix any outstanding nil-returns and consider
pinning golint in a future PR.

* Create new TaskInfo object to avoid memory issues

* Create ContainerTaskRels in dcos-metrics.go

Rather than initiating ContainerTaskRels in the framework collector, we
now initiate it in dcos-metrics.go and pass a reference into each
collector instead.

* Initiate ContainerTaskRels with a utility method

* Remove unnecessary nil check
philipnrmn added a commit to mesosphere-backup/dcos-metrics that referenced this pull request Sep 19, 2017
* Export TaskInfo from the mesos agent collector

We will reference TaskInfo in a map of container IDs to task info in a
later commit.

* Add a struct for container->task relationships

ContainerTaskRels has a single member, a map of container IDs to
TaskInfo references. It has a getter and a setter for easy access
threadsafe access to the relationship map, and an update method which
populates it from agentState.

* Return task_id and task_name in /app output

The new ContainerTaskRels argument providers access to the task metadata
for each container.

* Add tests for extracting a record with task data

We add a new mock object with appropriate metadata and supply it to
avroRecord.extract(), checking that the task IDs in the
ContainerTaskRels are the same ones that correspond to the container
ID.

* Add tests for executor ID and framework ID

This is orthogonal to the intent of this PR, however it's a small change
and seemed like a quick win.

* Refer to ContainerTaskRels in Framework collector

This reference can be provided to the extract method from the framework
collector.

* Pass ref to ContainerTaskRels into transform

* Update task mapping from agent collector

We update the task mapping after every new fetch from agent state.

* Pass reference to mapping into framework collector

Now the framework collector has access to the ContainerTaskRels object
which belongs to the mesos agent collector.

* Clarify arg name

* Defer unlock for consistency

* Temporarily skip golint in build

In scripts/test.sh we naively run go get to update golint. A new rule
has just been added to golint (golang/lint#319)
and I don't want to complicate my current PR (#118).

I will revert this commit, fix any outstanding nil-returns and consider
pinning golint in a future PR.

* Create new TaskInfo object to avoid memory issues

* Create ContainerTaskRels in dcos-metrics.go

Rather than initiating ContainerTaskRels in the framework collector, we
now initiate it in dcos-metrics.go and pass a reference into each
collector instead.

* Initiate ContainerTaskRels with a utility method

* Remove unnecessary nil check
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants