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

SH.FLOW.CheckCodeReturn #121

Closed
8 of 9 tasks
WaldoFR opened this issue Jun 14, 2018 · 1 comment · Fixed by #156
Closed
8 of 9 tasks

SH.FLOW.CheckCodeReturn #121

WaldoFR opened this issue Jun 14, 2018 · 1 comment · Fixed by #156

Comments

@WaldoFR
Copy link

WaldoFR commented Jun 14, 2018

Implementation of the rule SH.FLOW.CheckCodeReturn.

Description

It's mandatory to verify error's code returned by any command or execution called by a shell script.

Known problems

Commands execution handling

Description : Parseur behaviour becomes inaccurate when reading a command execution.

  • Fixed

Pipe handling

Description : On a pipiline, where the first function hsouldn't be verified and that there is only one function to verify in the pipe line, the violation message is the one intended to simples functions. Also, raising false positive on || use.
Code example :

  • grep "Date :" $ficresarc | awk '{print $3}' > datejul.tmp
  • cd -- "$idir" || { echo >&2 can not cd to "$idir"; exit 1; }
  • Fixed

Test handling

Description : The checker raise a violation when the test returned isn't like if [ $? -eq 0].

  • Fixed

Last file's violation is on a wrong line

Description : The last violation detected by the checker on a file is set on the previous line of the violation.
Code example :

cd testdir
date +%d_%m_%y > newfile
retour=$?
ls
  • Fixed

Function declaration

Description : The checker is not handling some types of functions declaration. The problem is the same one as defined for several rules in #49 . This might also be the reason a false positive violation raise when a function name isn't clearly defined.

  • Fixed

Exports handling

Description : The checker raises false positive on export use.
Code example : export –f funcName

  • Fixed

State of the implementation

  • Violation raising
  • Localization
  • Unit tests
@WaldoFR WaldoFR added this to Backlog in i-Code CNES 3.1.0 via automation Jun 14, 2018
@WaldoFR WaldoFR added this to the Version 3.1.0-alpha.6 milestone Jun 19, 2018
brigittehuynh added a commit that referenced this issue Jul 22, 2018
(including case-esac). Tests updated accordingly.
Issue #137 remains valid).
@brigittehuynh brigittehuynh moved this from Backlog to To do in i-Code CNES 3.1.0 Sep 9, 2018
@brigittehuynh brigittehuynh moved this from To do to In progress in i-Code CNES 3.1.0 Sep 9, 2018
brigittehuynh added a commit that referenced this issue Sep 11, 2018
 - simple pipe command gets correct violation message
 - || no longer recognized as a pipe
 - different test management is supported
 - the last violation is on the correct line
 - no false positive on export command
 The test files have been updated accordingly.
@brigittehuynh
Copy link
Collaborator

brigittehuynh commented Sep 11, 2018

The rule is corrected, with a limitation: $(command) style commands are not looked into. They do not interfere with the rest of the code.

@brigittehuynh brigittehuynh moved this from In progress to Done in i-Code CNES 3.1.0 Sep 11, 2018
@WaldoFR WaldoFR mentioned this issue Sep 13, 2018
begarco pushed a commit to begarco/i-CodeCNES that referenced this issue Jan 25, 2020
… localization

(including case-esac). Tests updated accordingly.
Issue cnescatlab#137 remains valid).
begarco pushed a commit to begarco/i-CodeCNES that referenced this issue Jan 25, 2020
 - simple pipe command gets correct violation message
 - || no longer recognized as a pipe
 - different test management is supported
 - the last violation is on the correct line
 - no false positive on export command
 The test files have been updated accordingly.
begarco pushed a commit that referenced this issue Feb 2, 2020
(including case-esac). Tests updated accordingly.
Issue #137 remains valid).
begarco pushed a commit that referenced this issue Feb 2, 2020
 - simple pipe command gets correct violation message
 - || no longer recognized as a pipe
 - different test management is supported
 - the last violation is on the correct line
 - no false positive on export command
 The test files have been updated accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants