Comment with //// without space - tslint

I want to enable comments without space in tslint if comment starts with 4 slashes.
Rule: https://palantir.github.io/tslint/rules/comment-format/
I've tried
"comment-format": [true, "check-space", { "ignore-pattern": "//" }],
but it didn't helped.

From the documentation:
Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.
It seems one cannot attach ignored patterns to "check-space".

add next rule to tslint.json:
"comment-format": [false, "check-space"]

Related

In Pylint, how do I disable "Exactly one space after comma" for multidimensional array indices?

I like having PyLint check that commas are generally followed by spaces, except in one case: multidimensional indices. For example, I get the following warning from Pylint:
C: 31, 0: Exactly one space required after comma
num_features = len(X_train[0,:])
^ (bad-whitespace)
Is there a way to get rid of the warnings requiring spaces after commas for the case multidimensional arrays, but keep the space-checking logic the same for all other comma uses?
Thanks!
I am sure you figured this out by now but for anyone, like me, who happened upon this looking for an answer...
use # pylint: disable=C0326 on the line that is guilty of this. for instance:
num_features = len(X_train[0,:]) #pylint: disable=C0326
This applies to multiple kinds of space errors. See pylint wiki
You'll almost certainly want to disable this via the .pylintrc file for larger situations.
Example, say I have:
x111 = thing.abc(asdf)
x112_b = thing1.abc(asdf)
x112_b224 = thing.abc(asdf)
x112_f = thing1.abc(asdf)
... lots more
Now, presume I want to visually see the situation:
x111 = thing.abc(asdf)
x112_b = thing1.abc(asdf)
... lots more
so I add the following line to .pylintrc
disable=C0326,C0115,C0116
(note only the first one, c0326, counts, but I'm leaving two other docstring ones there so you can see you just add err messages you want to ignore.)

How to change comment formatting in VS Code

I am having the opposite problem than this question: In a SASS .scss file, I want comments command (ctrl/⌘ + /, ctrl/⌘ + K ctrl/⌘ + C) to default to //, and use the Block comment /* ... */ only when using the block comment (shift+alt+A).
I have been unable to find a way to change this setting, via the user settings or even a plugin. Is it possible? Is my google-fu just bad?
A very belated answer, but you can amend the language-configuration.json file for the language in question. More here: https://code.visualstudio.com/api/language-extensions/language-configuration-guide.

Yii basic url rewrite

I am new to php, new to mvc, new to yii, and new to url-rewriting. So, I am sorry, if I am asking something very basic.
I have hide the index.php (from the htaccess method discussed in yii forums)
In my urlmanager, I have this,
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>'
),
'showScriptName'=>false,
I have 3 files in view/site folder.
'journey',
'invite',
'linkedin'
Now, my home page should redirect to 'journey' action (i.e. should open the 'site/journey.php')
So, I guess, this would be
'/' => 'site/journey'
It works too.
Now, I want 'journey/invite' should invoke the 'invite' action i.e. should open 'site/invite.php'
And, 'journey/linkedin' should invoke the 'linkedin' action i.e. 'site/linkedin.php'.
but,
'journey/invite' => 'site/invite',
'journey/linkedin' => 'site/linkedin'
is not working.
Also, can someone help me understand this,
<controller:\w+>/<id:\d+>
i.e. what is controller in url and what does 'w+' mean ?
A reference to guide will help too.
Edited after bool.dev's suggestion:
Changed the code , as you said (I tried that earlier too, removing all default rules).
Now my url manager is like,
'/' => 'site/journey',
'journey/invite' => 'site/invite',
'journey/linkedin' => 'site/linkedin',
'<controller:\w+>/<id:\d+>'=>'view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
But it throws an error
"Warning: require_once(): open_basedir restriction in effect.
File(/var/xyz.com/../yii/framework/yii.php) is not within the allowed
path(s):
(/usr/share/php:/usr/share/pear:/usr/share/php/libzend-framework-php:/var/*/tmp:/var/xyz.com)
in /var/xyz.com/journey.php on line 12 Warning:
require_once(/var/xyz.com/../yii/framework/yii.php): failed to open
stream: Operation not permitted in /var/xyz.com/journey.php on line 12
Fatal error: require_once(): Failed opening required
'/var/xyz.com/../yii/framework/yii.php'
(include_path='.:/usr/share/php:/usr/share/php/libzend-framework-php')
in /var/xyz.com/journey.php on line 12'
when I do xyz.com/journey/invite or even xyz.com/journey
Edit:
It was a permission issue, #bool.dev's suggestion to put specific rules on top worked :)
These two:
'journey/invite' => 'site/invite',
'journey/linkedin' => 'site/linkedin'
are not working because the url is being matched by a previous rule:
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>'
To prevent that from happening just make sure that rule is mentioned last, before any specific(i.e not matched by regular expressions) rewrites, so your rules can look somewhat like this :
'journey/invite' => 'site/invite',
'journey/linkedin' => 'site/linkedin',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>'
This : \w+ means match any string with one or more occurrences of any “word” character (a-z 0-9 _) and \d+ means match any string with one or more occurrences of any digits (0-9) . Check out php regex.
Edit
Hadn't read your question thoroughly before, the controller in the rule is simply a name for the matched expression, so you could have had '<contr:\w+>/<act:\w+>'=>'<contr>/<act>'.
Edit2
After reading your edited question with the rules array, afaik you could use ''=>'site/journey' instead of '/'=>'site/journey'.

How do I match a full link in capybara?

In Capybara+Rspec, I can check that a link is missing:
response.body.should_not have_link("link_content")
This is fine, but unfortunately the test fails for when "link_content" partially matches a link, such as "this_is_a_long_link_content". How can I change the test to make it pass in this case?
(That is, the matcher should not partially match, it should only fully match).
You can also use the following workaround:
response.body.should_not have_xpath("//a[normalize-space(text())='link_content']")
This is whitespace-agnostic and therefore a little more flexible than the raw HTML approach.
From the docs:
If all else fails, you can also use the page.html method to test against the raw HTML:
This works for me:
page.html.should match('>\s*Log in\s*</a>')
page.html.should_not match('>\s*link_content\s*</a>')
Note that the argument to match can a regular expression. That means that you can make the solution whitespace-agnostic by simply adding \s*.

JMeter "if controller" with parameters?

I was reading the JMeter documentation and came across this info box about "If Controllers":
No variables are made available to the script when the condition is interpreted as Javascript. If you need access to such variables, then select "Interpret Condition as Variable Expression?" and use a __javaScript() function call. You can then use the objects "vars", "log", "ctx" etc. in the script.
I don't quite follow this. Does this mean if I want access to a "User Defined Parameter" then I can access it only by writing some JavaScript? The example that follows this box then refers to "${COUNT}"
Could someone clarify the usage of the If Controller, maybe with an example or two?
All these answers are wrong! You need to put the variable reference in quotes, like so:
"${my_variable}"=="foo"
You can simply use something like
${my_variable}=='1'
Sometimes JMeter documentation can be confusing :)
Edit 27 september 2017:
The answer here works but has a very bad performance impact when number of threads exceeds 40.
See below for correct and most performing answer:
https://stackoverflow.com/a/46976447/460802
See:
https://bz.apache.org/bugzilla/show_bug.cgi?id=61675
UNCHECK the CHECKBOX
"Interpret condition as variable expression"
I wasted a couple of hours without unchecking this checkbox. It worked with and without semicolon(;) at the end of the statement. Make sure that you have set the User-Defined Variables before calling the if controller.
All the following variations worked for me in Jakarta Jmeter 1.5
${__javaScript("${HOMEPAGE}"=="Y")}
${__javaScript("${HOMEPAGE}"=="Y")};
"${HOMEPAGE}"=="Y"
"${HOMEPAGE}"=="Y";
If Controller will internally use javascript to evaluate the condition but this can have a performance penalty.
A better option (default one starting from JMeter 4, see https://bz.apache.org/bugzilla/show_bug.cgi?id=61675) is to check "Interpret Condition as Variable Expression?", then in the condition field you have 2 options:
Option 1 : Use a variable that contains true or false. For example If you want to test if last sample was successful, you can use
${JMeterThread.last_sample_ok}
or any variable you want that contains true/false
${myVar}
Option 2 : Use a function (${__jexl3()} is advised) to evaluate an expression that must return true or false.
For example if COUNT is equal to 1:
${__jexl3("${COUNT}"== "1",)}
OR
${__jexl3(${COUNT}== 1,)}
Starting with 4.0, if you don't use the "Interpret Condition as Variable Expression?", a warning in RED will be displayed:
If you'd like to learn more about JMeter and performance testing this book can help you.
God bless the http://habrahabr.ru
Have tried until found these.
Using the quotes was my solution.
As Gerrie said you need to check your variable
${my_var} == 'value'
But be careful with the 'User Defined Variables'
Note that all the UDV elements in a
test plan - no matter where they are -
are processed at the start.
That basically means that you cannot define 'User Defined Variables' inside an 'If Controller'. Take a look to the 'BeanShell' instead.
Replace:
${my_variable}=='1'
with
"${my_variable}" == "1"
if it's string value pass as below and its performance effective
${__groovy("${key}"=="value")}
I have used ${code_g1}== 200 in condition and it worked for me.

Resources