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

Add a NilAway config analyzer for parsing and sharing configurations #9

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

yuxincs
Copy link
Contributor

@yuxincs yuxincs commented Jul 25, 2023

This PR adds a separate psudo-analyzer for getting the flags and sharing them among the NilAway sub-analyzers.

This is required due to our multi-sub-analyzer architecture in NilAway: by the time the top-level analyzer is run, the analysis is already done (by the sub-analyzers), hence the flags controlling the analysis behaviors will be meaningless. Instead, we add this pseudo-analyzer to run first (since all sub-analyzers will depend on it), and make the flags available via its return value.

Unfortunately, this also means for some analyzer drivers (such as nogo), flags will have to be specified for this pseudo-analyzer ("nilaway_config"), and the error suppression lists will have to be specified for the top-level analyzer ("nilaway") since that is the one that outputs errors.

Two test packages ignoredpkg1 and ignoredpkg2 are added to ensure the flags are properly parsed and shared by the sub-analyzers.

This PR also adds an early-return logic for the accumulation analyzer: previously even if a package is skipped, we were still unnecessarily running the accumulation analyzer to "get" the empty results from sub-analyzers and run the inference.

Depends on #7

@yuxincs yuxincs self-assigned this Jul 25, 2023
"strings"
"time"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The non-user-configurable "configs" are moved to another file const.go in this package

Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All LGTM 🙂

@yuxincs yuxincs force-pushed the yuxincs/add-config-analyzer branch from f198d73 to f065d95 Compare July 26, 2023 15:41
@yuxincs yuxincs force-pushed the yuxincs/add-config-analyzer branch 2 times, most recently from ca3a1bb to cb84038 Compare July 29, 2023 03:03
Base automatically changed from yuxincs/add-linting to main July 31, 2023 17:14
@yuxincs yuxincs force-pushed the yuxincs/add-config-analyzer branch 3 times, most recently from 0c3b964 to 5606a36 Compare July 31, 2023 19:44
@yuxincs yuxincs force-pushed the yuxincs/add-config-analyzer branch from 5606a36 to 76f4078 Compare July 31, 2023 19:51
@yuxincs yuxincs merged commit 1438772 into main Jul 31, 2023
3 checks passed
@yuxincs yuxincs deleted the yuxincs/add-config-analyzer branch July 31, 2023 20:41
yuxincs added a commit that referenced this pull request Aug 4, 2023
This PR replaces the global variable `config.IsTestEnvironment` with a
user-configuration option `pretty-print` (default `true`). Then in our
`TestMain` setup function we set this flag to be false for testing
purposes.

Depends on #9
yuxincs added a commit that referenced this pull request Aug 4, 2023
This PR removes the hardcoded `nolint:nilaway` docstring check for both
files and function declarations since it is no longer necessary:

* files: we have implemented configuration analyzer in #9 which is able
to take a list of strings to ignore the analysis of a file.

* function declaration: it is mainly designed for two reasons:
* performance: we were able to use it to manually skip the analysis of a
particular function for performance reasons. However, we now have a
timeout for analysis of any particular function, hence this is no longer
required.
* error suppression: most linter drivers, especially nogo, are now
respecting `nolint`, so there is really no need to support it within the
linter itself.

Depends on #10
sonalmahajan15 pushed a commit that referenced this pull request Aug 5, 2023
This PR replaces the global variable `config.IsTestEnvironment` with a
user-configuration option `pretty-print` (default `true`). Then in our
`TestMain` setup function we set this flag to be false for testing
purposes.

Depends on #9
sonalmahajan15 pushed a commit that referenced this pull request Aug 5, 2023
This PR removes the hardcoded `nolint:nilaway` docstring check for both
files and function declarations since it is no longer necessary:

* files: we have implemented configuration analyzer in #9 which is able
to take a list of strings to ignore the analysis of a file.

* function declaration: it is mainly designed for two reasons:
* performance: we were able to use it to manually skip the analysis of a
particular function for performance reasons. However, we now have a
timeout for analysis of any particular function, hence this is no longer
required.
* error suppression: most linter drivers, especially nogo, are now
respecting `nolint`, so there is really no need to support it within the
linter itself.

Depends on #10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants