SonarQube Rule plsql:QuotedIdentifiersCheck fails - plsql

This SonarQube rule checks that Quoted identifiers are not used.
But SQL syntax requires quotes when column alias is composed with a space.
Agree with the rule when developers create such variable:
"hello" VARCHAR2(42) := 'world';
but disagree for that:
Select myColA as "Column A",
myColB as "column B",
...
Sonar should not hit for alias in Select statement.
Correct ?

It seems reasonable. This improvement should be included in the next version of SonarPLSQL.

Related

R - Best Approach for Adding String To New Column Based on Two Conditions

I need assistance with identifying an effective approach in R for conditionally assigning values to a new column in a data matrix after testing to see if specific string exist in two columns. I am using R Studio for these manipulations (I would characterize my skills with R under the "working knowledge" thereof).
I experimented with an admittedly verbose series of if() else() statements with each containing two conditions. Unfortunately, the result in R Studio is "There were [x number] of warnings (use warnings()..." or "...the condition has length > 1 and only the first element will be used." I couldn't find a solution on my own (or after reading various forum posts that expressed similar issues).
My data matrix looks something like this in the R Studio console:
I want to add a new example column called "Tag" and so I tried something like the following:
>exampleTable["Tag"] <- if(exampleTable$Subject == "Subject 1" & exampleTable$Author = "Eminem"){"Tag 1"} else if (exampleTable$Subject == "Subject 1" & exampleTable$Author = "Freddie Mac"){"Tag 2"}
Ideally, a working solution would successfully test for the existence of specific string in the "Subject" and "Author" columns and the result would be the new "Tag" column with whatever new string we wanted to add such as "Tag 1", "Tag 2", etc.
I understand the example above doesn't work so what is a better approach to do this? Thanks!
Per comments from r2evans and coffeinjunky, ifelse() yielded the results I needed.

How to set a string value containing spaces into MapWebModToVH when using wsadmin

Currently I am trying to deploy an EAR file with wsadmin.sh. Using the following command:
wsadmin.sh -lang jython -conntype NONE -c "AdminApp.install('/tmp/Sample1.ear', '[ -appname Sample1 -contextroot /Sample1 -MapWebModToVH [[ Sample1 Sample1.war,WEB-INF/web.xml default_host]]]')"
However,
WASX7015E: Exception running command: "AdminApp.install('/tmp/sample1.ear', '[ -appname Sample1 -contextroot /Sample1 -MapWebModToVH [[ Sample1.war
Sample1.war,WEB-INF/web.xml default_host]]]')"; exception information:
com.ibm.ws.scripting.ScriptingException: WASX7111E: Cannot find a match for supp
lied option: "[Sample1, Sample1.war,WEB-INF/web.xml, default_host]" for task
"MapWebModToVH". The supplied option must match with the existing task data in
the application and the existing task data are: "["Sample Web Application" Sample1.war,WEB-INF/web.xml] "
Apparently the -MapWebModToVH should encorporate "Sample Web Application" as first value and not Sample1, but how should we do this since the parameters are seperated by a space. Using "Sample Web Application" as value with quotes does noet work. What is going wrong?
Use double quotes to enclose spaces within the single-quote-delimited string.
Since the outer string is delimited by single quotes, you can use double quotes within the quoted string value. (This is a feature of Python in general). E.g.:
AdminApp.install('/tmp/Sample1.ear', '[ -appname Sample1 -contextroot /Sample1 -MapWebModToVH [[ "Sample Web Application" Sample1.war,WEB-INF/web.xml default_host]]]')

Implementing SSML in Alexa Example

I am working on a modified version of the example trivia game skill with Alexa. Certain words in the questions can't be pronounced properly so I would like to implement an SSML phoneme spelling for those words. However adding in the full pecan style command breaks the message as the code sees it as unbalancing brackets, but not enclosing it in quotations creates an unresolved regular expression. Does anyone have any recommendations how I can include it as x-sampa SSML while still keeping it as the currently implemented var? Here is an example of how it is currently breaking.
{
"Test question 1?": [
"Answer 1",
"<phoneme alphabet="x-sampa" ph="EksIlUs">Exilus</phoneme> Adapter",
"Answer 3",
"Answer 4"
]
},
Your problem is likely the fact that you're wrapping your SSML string in double quotes, but then also including non-escaped double quotes in the SSML itself. To solve this, try either replacing the quotes in the SSML with single quotes, or escaping them with the backslash character like this:
{
"Test question 1?": [
"Answer 1",
"<phoneme alphabet=\"x-sampa\" ph=\"EksIlUs\">Exilus</phoneme> Adapter",
"Answer 3",
"Answer 4"
]
},
If you look at the example Alexa skills which use SSML, you'll see that that's how they're handling quotes:
speechText = "That's not how knock knock jokes work! <break time=\"0.3s\" /> "
+ "Knock knock!";

Why is white space significant in test scripts?

I found that I had to put 2 spaces instead of 1 to make testcases be interpreted correctly, for eg:
Set Selenium Timeout<2 spaces>60
This is very unintuitive. Is this by design?
yes, this is by design.
The idea is that when you write test cases in Robot Framework, they can be read as "specifications" or "plain english" as much as possible. So it is possible to have spaces in keywords so you can name them like "log file should be in directory" or "status code from http server should be" and to distinguish those keywords from the argument you need to have more than one space (hence the "minimum 2").

shell script detect first couple letters

I'm writing a shell script. A variable will have a url that will look at the the beginning few characters and
make sure there is something before the //...so a http, https,rtmp,rtmps,rtmpe,etc....
if nothing is in front of the // then tell user there is nothing...else if that value = whatever do whatever
How would I be able to do this?
case "$URL" in
http://*|https://*) echo "HTTP selected" ;;
ftp://*|ftps://*) echo "FTP selected" ;;
*) echo "Nothing selected" ;;
esac
Firstly you should should try coding this in some language such as perl or ruby that has extensive built-in regex capabilities. However if you really wish to do this in shell, then the sting operators are your friend:
url="something://and something else"
${url%%://*} will extract "something", i. e. the protocol being used.
${url##*://} will extract "and something else" i.e. everything to the right of ://
Ignacio has demonstrated how to do straight string matching, and ennuikiller has shown some of bash's pattern matching capabilities. But for what it's worth (and perhaps as surprising to others as to me), bash is indeed capable of full regexp pattern matching:
An additional binary operator, =~,
is available, with the same precedence
as == and !=. When it is used, the
string to the right of the operator
is considered an extended regular
expres‐ sion and matched accordingly
(as in regex(3)).
This was in the description of the [[ ]] operators for expression evaluation.

Resources