-
Notifications
You must be signed in to change notification settings - Fork 20
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
Improves Doc with sonar_rules_reused.md and passing it to tooling (sh scripts) #18
Improves Doc with sonar_rules_reused.md and passing it to tooling (sh scripts) #18
Conversation
tools/rules_config/_core.sh
Outdated
done | ||
done | ||
} < $FILEPATH_SONAR_RULES_REUSED | ||
debug "Extracting rules: ${rules_keys::-1} \n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on my local machine (MAC OSx), I have an error on lines with "::-1" string :
_core.sh: line 44: -1: substring expression < 0
thus my questions :
- why not use ":-1" string value instead of "::-1" ?
- why do you want to affect the default value
1
to rules_key ? for me no pb if no value in this variable. this use case is controlled => we will have an error likeERROR - config parameter 'RULES_KEYS' is NOT valid : it can't be empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I concatenate each keys with a comma. The use of operator ::-1
is here to delete the last comma i have added.
I have tested for the experience:
debug "Extracting rules: ${rules_keys::-1} \n"
RULES_KEYS=${rules_keys:-1}
--- DEBUG --- Read file ./SONAR_RULES_REUSED.md
--- DEBUG --- Extracting rules: css:S4655,php:S2014,Web:ItemTagNotWithinContainerTagCheck
--- DEBUG --- SONAR_TOKEN : xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
--- DEBUG --- SONAR_URL : http://localhost:9000
--- DEBUG --- RULES_KEYS : css:S4655,php:S2014,Web:ItemTagNotWithinContainerTagCheck,
--- DEBUG --- TAG_ECOCONCEPTION : test1
You will see the comma not deleted with :-1
.
i find why you have a bug.... It's a function from bash 4.2 and you must have bash 3 if i'm looking the readme :D delete-the-last-character-of-a-string-using-string-manipulation-in-shell-script
I will look for an older method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use ZSH to launch scripts ... here are my versions (ZSH but also BASH if you want)
~ ❯ zsh --version
zsh 5.9 (x86_64-apple-darwin22.0)
~ ❯ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin22)
Copyright (C) 2007 Free Software Foundation, Inc.
~ ❯
tools/rules_config/_core.sh
Outdated
done | ||
} < $FILEPATH_SONAR_RULES_REUSED | ||
debug "Extracting rules: ${rules_keys::-1} \n" | ||
RULES_KEYS=${rules_keys::-1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same feedback as above
@dedece35 , i replace with a sed function to got compatibility with your bash version.
|
Objectives
Gives a better comprehension of rules needed to be tag by "eco-design"
Gives a one entry point to adding rules. (Not have to copy/paste new rules... risk to desync)
Execution
After testing script on my Ubuntu wsl, you wil got this log bash:
Will need a PR about "ecoconception" key word to switch to "ecodesign" like main repo.
I have also identify the script shell not failed in error if your token is not a user token.