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 new line linter #2875

Merged
merged 6 commits into from
Apr 13, 2022
Merged

Conversation

owaiskazi19
Copy link
Member

Description

Added a new-line linter to make sure all files end with a single newline. This is a POSIX standard, read more https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline. Thanks @peternied for introducing it.

Issues Resolved

#2857

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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.

@owaiskazi19 owaiskazi19 requested a review from a team as a code owner April 12, 2022 19:09
@owaiskazi19 owaiskazi19 changed the title Added new line linter Added a new line linter Apr 12, 2022
@owaiskazi19 owaiskazi19 force-pushed the new-linter branch 2 times, most recently from 7b6ed41 to 94e63c7 Compare April 12, 2022 19:28
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 92b274adf2dcd58e13827471cc7294ffb0649dad
Log 4410

Reports 4410

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 7b6ed41b889be5f1a13af473ab85631c053309f8
Log 4411

Reports 4411

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

Nice!

@@ -0,0 +1,14 @@
name: Code Hygiene
Copy link
Member

Choose a reason for hiding this comment

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

I'd recommend renaming the file name to match the workflow name, new-line -> code-hygiene. In the future you could add addition jobs that scanned for other hygiene related issues.

@tlfeng
Copy link
Collaborator

tlfeng commented Apr 12, 2022

In log 4411:

REPRODUCE WITH: ./gradlew ':server:test' --tests "org.opensearch.action.bulk.BulkRequestTests.testBulkTerminatedByNewline" -Dtests.seed=F8AC59B864ACF83D -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=zh-Hans-SG -Dtests.timezone=CTT -Druntime.java=17

org.opensearch.action.bulk.BulkRequestTests > testBulkTerminatedByNewline FAILED
    junit.framework.AssertionFailedError: Expected exception IllegalArgumentException but no exception was thrown
        at __randomizedtesting.SeedInfo.seed([F8AC59B864ACF83D:5C8957B388059622]:0)
        at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2898)
        at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2884)
        at org.opensearch.action.bulk.BulkRequestTests.testBulkTerminatedByNewline(BulkRequestTests.java:363)

REPRODUCE WITH: ./gradlew ':server:test' --tests "org.opensearch.action.search.MultiSearchRequestTests.testMsearchTerminatedByNewline" -Dtests.seed=F8AC59B864ACF83D -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=sv -Dtests.timezone=America/Tegucigalpa -Druntime.java=17

org.opensearch.action.search.MultiSearchRequestTests > testMsearchTerminatedByNewline FAILED
    junit.framework.AssertionFailedError: Expected exception IllegalArgumentException but no exception was thrown
        at __randomizedtesting.SeedInfo.seed([F8AC59B864ACF83D:61D0ED2E2B325170]:0)
        at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2898)
        at org.apache.lucene.tests.util.LuceneTestCase.expectThrows(LuceneTestCase.java:2884)
        at org.opensearch.action.search.MultiSearchRequestTests.testMsearchTerminatedByNewline(MultiSearchRequestTests.java:320)

> Task :rest-api-spec:yamlRestTest

REPRODUCE WITH: ./gradlew ':rest-api-spec:yamlRestTest' --tests "org.opensearch.test.rest.ClientYamlTestSuiteIT" -Dtests.method="test {p0=cluster.state/20_filtering/Filtering the cluster state returns cluster_uuid at the top level regardless of metric filters}" -Dtests.seed=F8AC59B864ACF83D -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=be-BY -Dtests.timezone=America/Glace_Bay -Druntime.java=17

org.opensearch.test.rest.ClientYamlTestSuiteIT > test {p0=cluster.state/20_filtering/Filtering the cluster state returns cluster_uuid at the top level regardless of metric filters} FAILED
    java.lang.AssertionError: Failure at [cluster.state/20_filtering:168]: got unexpected warning header [
    	299 OpenSearch-3.0.0-SNAPSHOT-b3af34c2171764a767dea668b6969b20434103db "Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version."
    ]
        at __randomizedtesting.SeedInfo.seed([F8AC59B864ACF83D:70F86662CA5095C5]:0)
        at org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase.executeSection(OpenSearchClientYamlSuiteTestCase.java:451)
        at org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase.test(OpenSearchClientYamlSuiteTestCase.java:424)

The last test failure is caused by a PR merged yesterday that changed the expected warning message by mistake in the commit 07fc06d (of PR #2678), which makes the deprecation warning is not the same as the expected in the test.

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 94e63c7a15fbb7e10b06db3cae1386a3621f646e
Log 4412

Reports 4412

Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 4827228a2b6e274b98a0da5ff508962aaa26f638
Log 4413

Reports 4413

Signed-off-by: Owais Kazi <[email protected]>
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success c92d1b6
Log 4416

Reports 4416

@dblock dblock merged commit 3c5d997 into opensearch-project:main Apr 13, 2022
@dblock dblock added the backport 2.x Backport to 2.x branch label Apr 13, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 13, 2022
* Added linter to add new line

Signed-off-by: Owais Kazi <[email protected]>

* Fixed new lines

Signed-off-by: Owais Kazi <[email protected]>

* Ignore empty files

Signed-off-by: Owais Kazi <[email protected]>

* Updated DEVELOPER GUIDE

Signed-off-by: Owais Kazi <[email protected]>

* Renamed workflow file

Signed-off-by: Owais Kazi <[email protected]>

* Fixed failing tests

Signed-off-by: Owais Kazi <[email protected]>
(cherry picked from commit 3c5d997)
dblock pushed a commit that referenced this pull request Apr 13, 2022
* Added a new line linter (#2875)

* Added linter to add new line

Signed-off-by: Owais Kazi <[email protected]>

* Fixed new lines

Signed-off-by: Owais Kazi <[email protected]>

* Ignore empty files

Signed-off-by: Owais Kazi <[email protected]>

* Updated DEVELOPER GUIDE

Signed-off-by: Owais Kazi <[email protected]>

* Renamed workflow file

Signed-off-by: Owais Kazi <[email protected]>

* Fixed failing tests

Signed-off-by: Owais Kazi <[email protected]>
(cherry picked from commit 3c5d997)

* Fixed new lines

Signed-off-by: Owais Kazi <[email protected]>

Co-authored-by: Owais Kazi <[email protected]>
@dblock
Copy link
Member

dblock commented Apr 13, 2022

@owaiskazi19 I'm not going to backport this into 2.0, I think we can let that one be

@owaiskazi19
Copy link
Member Author

@owaiskazi19 I'm not going to backport this into 2.0, I think we can let that one be

Sounds good. Thanks for the review and taking care of the 2.x backport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants