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

Added a linter for order of parameters. #369

Merged
merged 3 commits into from
Jun 30, 2024

Conversation

dblock
Copy link
Member

@dblock dblock commented Jun 28, 2024

Description

Require parameters to be sorted.

Here's a silly Ruby script to apply a sort for next linter that needs sorted something.

Dir["spec/**/*.yaml"].each do |filename|
    puts filename
    lines = []
    File.open(filename, "r") do |f|
        params = []
        in_params = false
        f.each_line do |line|
            if line.include?('parameters:')
                lines << line
                in_params = true
            elsif in_params && line.include?("- $ref: ")
                params << line
            elsif in_params && params.size > 0
                lines.concat(params.sort)
                lines << line
                params = []
                in_params = false
            else
                lines << line
            end
        end
    end
    File.open(filename, "w+") do |f|
        f.puts(lines)
    end
end

Issues Resolved

Closes #352.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

Changes Analysis

Commit SHA: d159d87
Comparing To SHA: ed3fb4d

API Changes

Summary

NO CHANGES

Report

The full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/9717493002/artifacts/1649807241

API Coverage

Before After Δ
Covered (%) 483 (47.31 %) 483 (47.31 %) 0 (0 %)
Uncovered (%) 538 (52.69 %) 538 (52.69 %) 0 (0 %)
Unknown 24 24 0

@@ -12,6 +12,7 @@
"lint--fix": "eslint . --fix --report-unused-disable-directives",
"merge": "ts-node tools/src/merger/merge.ts",
"test": "npm run test:unit && npm run test:integ",
"jest": "jest",
Copy link
Member Author

Choose a reason for hiding this comment

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

I put this back because to run an individual test you can't do npm run test:unit -- ...test.ts, it has testMatch flags, but you can do npm run jest -- ...test.ts.

@Xtansia Xtansia merged commit e96f70d into opensearch-project:main Jun 30, 2024
19 checks passed
@dblock dblock deleted the order-of-parameters branch July 1, 2024 00:24
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.

[FEATURE] Sort spec fields (e.g. parameters)
2 participants