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 shellcheck support #190

Merged
merged 4 commits into from
Mar 7, 2021
Merged

Add shellcheck support #190

merged 4 commits into from
Mar 7, 2021

Conversation

dswiecki
Copy link
Contributor

@codecov-io
Copy link

codecov-io commented Jun 29, 2018

Codecov Report

Merging #190 (5fa1143) into master (aa51743) will increase coverage by 2.65%.
The diff coverage is 77.63%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #190      +/-   ##
============================================
+ Coverage     72.38%   75.03%   +2.65%     
- Complexity      608      659      +51     
============================================
  Files           146      154       +8     
  Lines          1988     2079      +91     
  Branches        131      134       +3     
============================================
+ Hits           1439     1560     +121     
+ Misses          489      456      -33     
- Partials         60       63       +3     
Impacted Files Coverage Δ Complexity Δ
...ocessor/shellcheck/ShellcheckProcessorFactory.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...tnik/processor/shellcheck/ShellcheckException.java 50.00% <50.00%> (ø) 1.00 <1.00> (?)
...k/processor/shellcheck/json/ShellcheckMessage.java 54.54% <54.54%> (ø) 6.00 <6.00> (?)
...tnik/processor/shellcheck/ShellcheckProcessor.java 76.92% <76.92%> (ø) 6.00 <6.00> (?)
...utnik/processor/shellcheck/ShellcheckExecutor.java 85.71% <85.71%> (ø) 5.00 <5.00> (?)
...k/processor/shellcheck/ShellcheckResultParser.java 91.66% <91.66%> (ø) 10.00 <10.00> (?)
...a/pl/touk/sputnik/configuration/GeneralOption.java 98.50% <100.00%> (+0.09%) 3.00 <0.00> (ø)
...ain/java/pl/touk/sputnik/exec/ExternalProcess.java 76.92% <100.00%> (+76.92%) 4.00 <0.00> (+4.00)
...ava/pl/touk/sputnik/review/filter/ShellFilter.java 100.00% <100.00%> (ø) 1.00 <1.00> (?)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa51743...5fa1143. Read the comment docs.

@SpOOnman
Copy link
Collaborator

Hej @dswiecki do you want to continue work on this PR?

@dswiecki
Copy link
Contributor Author

@SpOOnman I've updated PR

Copy link
Collaborator

@SpOOnman SpOOnman left a comment

Choose a reason for hiding this comment

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

Thank you for your support!

I think there is a problem with shellcheck as it is a shell script. It is hard to run tests with it because we need an environment that has it installed. Please correct me if I'm wrong as I don't know this tool.

}

String runOnFile(String filePath) {
log.info("Review on file: " + filePath);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use {} for string interpolation here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return Collections.emptyList();
}
try {
List<Violation> violations = new ArrayList<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be more readable with Java Stream API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, done

}

@Test
public void shouldReturnNoViolationsWhenThereIsNoFileToReview() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why there is no Assumption here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case, the file to review does not exist thus the processor is not invoked


@Test
public void shouldReturnOneViolationsForFile() {
Assumptions.assumeTrue(isShellcheckInstalled());
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test will pass only if shellcheck is intalled, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, otherwise it is ignored

private boolean isShellcheckInstalled() {
try {
String result = new ExternalProcess().executeCommand("shellcheck");
return "".equals(result);
Copy link
Collaborator

Choose a reason for hiding this comment

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

return StringUtils.isBlank(result) maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


String runOnFile(String filePath) {
log.info("Review on file: " + filePath);
return new ExternalProcess().executeCommand(buildParams(filePath));
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if shellcheck is not installed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then ExternalPorcess throws ExternalProcessException which is not handled specially like in the case of other ProcessorRunningExternalProcess processors

@dswiecki
Copy link
Contributor Author

@SpOOnman on travis-ci there's shellcheck script installed by default

@dswiecki dswiecki requested a review from SpOOnman February 12, 2021 15:47
@SpOOnman
Copy link
Collaborator

SpOOnman commented Mar 7, 2021

Thank you!

@SpOOnman SpOOnman merged commit a14d3a2 into TouK:master Mar 7, 2021
@austinarrowsmith
Copy link
Contributor

@dswiecki - how do you now run sputnik with a shellcheck-enabled system? I've tried setting shellcheck.enabled=true in the sputnik.conf file, but it doesn't appear to be executed. Can you help advise what's needed? I'm happy to push in another README documentation patch.

rufuslevi pushed a commit to rufuslevi/sputnik that referenced this pull request Mar 12, 2024
* Add basic shellcheck support

* Add shellcheck exclude rules

* Update junit annotations

* Shellcheck review
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.

5 participants