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

Capture unrecognized fields with lint #851

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Capture unrecognized fields with lint #851

wants to merge 16 commits into from

Conversation

nicholy
Copy link
Collaborator

@nicholy nicholy commented Aug 25, 2023

PR containing the current progress of updating the Spk lint command to capture typos and unrecognized config fields within the spk spec file. The current approach taken is to modify how the deserialize method works.

Example:

install:
  envionment:
    - priority: 99
  requirements:
    - pkg: python
      # we can use the version of python from the build environment to dynamically
      # define the install requirement
      fromBuildEnv: x.x

Outputs the error:

Failed temp-pkg.spk.yaml:
-----> Unrecognized key: enviroment. (Did you mean: 'environment'?)

@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

Attention: 94 lines in your changes are missing coverage. Please review.

Comparison is base (e8cf549) 53.55% compared to head (6684c0e) 53.37%.
Report is 215 commits behind head on main.

❗ Current head 6684c0e differs from pull request most recent head e8f7f43. Consider uploading reports for the commit e8f7f43 to get more accurate results

Files Patch % Lines
crates/spk-schema/src/lints.rs 38.00% 31 Missing ⚠️
crates/spk-schema/src/environ.rs 76.40% 21 Missing ⚠️
crates/spk-schema/src/v0/spec.rs 56.41% 17 Missing ⚠️
crates/spk-cli/group4/src/cmd_lint.rs 0.00% 13 Missing ⚠️
crates/spk-schema/src/install_spec.rs 65.71% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #851      +/-   ##
==========================================
- Coverage   53.55%   53.37%   -0.18%     
==========================================
  Files         258      258              
  Lines       20466    20474       +8     
==========================================
- Hits        10960    10928      -32     
- Misses       9506     9546      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@jrray jrray left a comment

Choose a reason for hiding this comment

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

I think you're on the right track, just some course corrections here to save on duplicate code.

crates/spk-schema/src/install_spec.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/install_spec.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/install_spec.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/v0/spec.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/v0/spec.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/v0/spec.rs Outdated Show resolved Hide resolved
@nicholy nicholy changed the title Spk lint update to capture typos and uncrecognized config fields in the spec file Draft: Spk lint update to capture typos and uncrecognized config fields in the spec file Aug 29, 2023
crates/lint_proc_macro/src/lib.rs Outdated Show resolved Hide resolved
crates/lint_proc_macro/src/lints.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/source_spec.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/source_spec.rs Outdated Show resolved Hide resolved
crates/lint_proc_macro/src/lib.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/environ.rs Outdated Show resolved Hide resolved
crates/spk-schema/Cargo.toml Outdated Show resolved Hide resolved
crates/spk-schema/src/build_spec.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/lints.rs Show resolved Hide resolved
crates/spk-schema/src/lints.rs Show resolved Hide resolved
crates/spk-schema/src/lints.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/requirements_list.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/spec.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/template.rs Outdated Show resolved Hide resolved
crates/spk-schema/src/v0/spec.rs Outdated Show resolved Hide resolved
@nicholy nicholy requested a review from jrray January 3, 2024 21:17
@nicholy nicholy changed the title Draft: Spk lint update to capture typos and uncrecognized config fields in the spec file Spk lint update to capture typos and unrecognized config fields in the spec file Jan 20, 2024
@nicholy nicholy added enhancement New feature or request SPI AOI Area of interest for SPI labels Jan 20, 2024
@nicholy nicholy changed the title Spk lint update to capture typos and unrecognized config fields in the spec file Capture unrecognized fields with lint Jan 20, 2024
Nichol Yip added 3 commits August 26, 2024 15:59
Signed-off-by: Nichol Yip <nyip@imageworks.com>
Signed-off-by: Nichol Yip <nyip@imageworks.com>
Signed-off-by: Nichol Yip <nyip@imageworks.com>
Nichol Yip added 10 commits August 26, 2024 16:01
Signed-off-by: Nichol Yip <nyip@imageworks.com>

Fixed error message when no similar configs are found.

Added linting for EnvOp

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Removed redudancy and simplified code.

WIP: Generalizing LintedItem struct across all config types.

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Added blanket implementation for LintedItem to generalize lints across all configs

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Moved lint logic into separate file.

Signed-off-by: Nichol Yip <nyip@imageworks.com>

WIP: enum for lint messages

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Moved lint error message inside new lint file.

Fixed error message when unknown key is found.

Implemented LintMessage enum for current variantions of lint error types.

Signed-off-by: Nichol Yip <nyip@imageworks.com>
Signed-off-by: Nichol Yip <nyip@imageworks.com>
Signed-off-by: Nichol Yip <nyip@imageworks.com>

WIP: Adding lint feature to source spec

Signed-off-by: Nichol Yip <nyip@imageworks.com>
Removed lint from spk-schema/crates/ident

Signed-off-by: Nichol Yip <nyip@imageworks.com>
Signed-off-by: Nichol Yip <nyip@imageworks.com>
Fixed configs to use Lint proc macro to generate lint messages

WIP: Add Lint proc macro for EnvOp and TestSpec

Signed-off-by: Nichol Yip <nyip@imageworks.com>
Signed-off-by: Nichol Yip <nyip@imageworks.com>
…-array crate instead.

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Fixed linting errors and removed unused commented code.

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Removed dead commented code and fixed du test with the correct sizes.

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Fixed issue where no default source spec if found when no source provided

Fixed issue with the default values for the meta struct when no values are provided

Reverted du command tests back as it was related to the issue with the source spec.

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Fixed typo in opentimelineio.spk.yaml

Added render logic to linting command that caused some packages to return an error without it.

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Added new line at EOF

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Fixed changes from rebase that was not correctly added.

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Removed shellexpand call from EnvOp

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Moved crates to top level cargo.toml

Changed linting feature to return an UnknownKey object instead of a generated string

Modified new method for UnknownKey to store values needed to generated lint message

Added enum for lints to support different kinds of lints

Removed commented code

Refactored render method and renamed render_lint -> render_to_string

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Fixed changes from rebase

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Fixed linting errors

Signed-off-by: Nichol Yip <nyip@imageworks.com>

WIP: Properly convert UncheckedBuildSpec -> BuildSpec

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Implmented LintedBuildSpec struct to properly evaluate error if any, in the visitor method instead of the from implementation.

Signed-off-by: Nichol Yip <nyip@imageworks.com>

Removed redundant struct and replaced with using LintedItem instead.

Signed-off-by: Nichol Yip <nyip@imageworks.com>
Signed-off-by: Nichol Yip <nyip@imageworks.com>
Nichol Yip added 3 commits August 27, 2024 14:36
Signed-off-by: Nichol Yip <nyip@imageworks.com>
Signed-off-by: Nichol Yip <nyip@imageworks.com>
Signed-off-by: Nichol Yip <nyip@imageworks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SPI AOI Area of interest for SPI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants