Can missing else blocks be globally ignored in Istanbul - istanbul

I have code that has multiple if statements but no corresponding else statements. I have been adding /* istanbul ignore else */ individually for all these if statements in order to ignore the corresponding missing else blocks. Is there are way to ignore all the missing else statement?

Per the current Istanbul documentation:
The way to ignore an "else path" coverage is: (/* istanbul ignore else */
In Ideas for Later the author is considering adding " "default-excludes": true," to the configuration file.
BOTTOM LINE:
it appears that in the current version, you must add /* istanbul ignore else */ to each block you wish to exclude.

Related

Woocommerce Order Export CSV Amendment to code

and a huge thank you to everyone who looks at this in advance from me..
I had some custom code made many moons ago which allowed us to create a new field in a CSV export file, generated by the Woocommerce CSV order export plugin. The field was based on a few rules to export a column called "tax".
It had much more complicated code setup surrounding procedures with Brexit and how we import tax data into Sage 50.
HOWEVER, I have amended the code but I don't really know PHP well. Essentially, I can see the code is trying to set a variable called "tax_code".
WHAT I NEED, is that if field 'shipping_country' equals "GB", then variable "tax_code" should be set in the export to "T1" OTHERWISE, "tax_code" should be "T0".
A snippet of the code is below and I'm pretty sure, if not hopeful, I don't need loads of code rewritten for me, I just need this amended correctly as and IF ELSE statement.
Is there anyone out there to help - much appreciated.
Regards Craig
$tax_code = "";
if (!in_array($order->shipping_country = "GB")) {
$tax_code = "T1";
}
else {
$tax_code = "T0";
}
$order_data['tax'] = $tax_code;
From what I can see the statement is doing the opposite to what you want it to do.
The clause !in_array($order->shipping_country = "GB")) means "not in_array" i.e. evaluates to FALSE. So for GB the else will set the tax_code.
You want to set the parameter $tax_code to T1 if that clause evaluates to TRUE.
If you have been getting the wrong outcome, try removing the exclamation mark so that the clause says in_array($order->shipping_country = "GB")) i.e shipping_country is GB, and you should then see the $tax_code parameter set to T1 as you expect.

LESS addition operator (+) is appending instead of adding

I'm having a strange issue I haven't seen occur. I am trying to do some basic addition to some variables like this:
#screen-break-sm: 768px;
#screen-break-md: 992px;
#screen-max-mobile: #screen-break-sm;
#screen-min-desktop: #screen-break-sm + 1;
Then, those values are being used in some media queries. When it is compiled using gulp-less (version ~3.0.0 in package.json) via Gulp, the output ends up being something like:
#media (min-width:768px + 1) {
// CSS
}
I'm expecting:
#media (min-width:769px) {
// CSS
}
I have tried doing the addition as both #screen-break-sm + 1 and also screen-break-sm + 1px. I've also tried removing the px part of the original values and doing the add and appending the px afterwards, but that doesn't add either.
In case it is relevant, this is one of the gulp scripts that builds a section where I first ran into this issue:
module.exports = function (build) {
return function () {
var pagesPath = build.options.styles.buildPath + '/pages/';
return build.gulp.src('./resources/assets/less/pages/**/*')
.pipe(build.plugins.less({
paths: [ build.plugins.path.join(__dirname, 'less', 'vendor', 'theme', 'bootstrap') ]
})).on('error', build.errorHandler)
.pipe(build.plugins.minifyCss()).on('error', build.errorHandler)
.pipe(build.plugins.extReplace('.min.css')).on('error', build.errorHandler)
.pipe(build.gulp.dest(pagesPath));
};
};
Any ideas why LESS is concatenating/appending instead of performing addition?
[EDIT]
While the solution is the same as the other question that was identified as a possible duplicate, that question does not discuss the problem that users will encounter directly, and therefore I think this question is much better suited for searching purposes. I never found that solution after an hour of Googling and only after getting the answer and the "strict math" verbiage did that other question show up.
Look at strict math option which default value is OFF. Are you sure that for some reason you don't have it set to ON?
lessc -sm=on
lessc --strict-math=on

How can I return the date in a custom format in this Qt/QML plasmoid?

The digital clock in KDE Plasma 5.4.0 does not allow you to specify a custom format. I'm attempted to hack the plasmoid, which is just a QML file. However, I've been unsuccessful. There is a conditional branch, which allows you select from one of the following strings.
return Qt.SystemLocaleLongDate;
return Qt.ISODate;
return Qt.SystemLocaleShortDate;
I attempted to modify it to the following, but it's not working. Presumably I just have the syntax wrong.
return QDate::currentDate().toString("dd.MM.yyyy");
How can I modify the plasmoid to show a custom date format?
EDIT
I suspect that I might be changing the wrong line. The source code for the plasmoid I'm trying to hack is here. After decompressing the file, it's specifically at applets/digital-clock/package/. (When installed, this directory is moved to /usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/.) I attempted changing line 43 of contents/ui/DigitalClock.qml.
I attempted changing the line to return "foo";, but this had no effect. Again, I'm not sure if I have the syntax correct.
As stated in the comments, the line returning this value isn't a reference to the date itself, but merely specifies the format. I'm unsure of the syntax to hack the code here, but instead, you can change the code that references this property later.
--- DigitalClock.qml.orig 2015-08-22 20:45:40.000000000 +1000
+++ DigitalClock.qml 2015-09-01 09:32:35.417197582 +1000
## -515,7 +515,7 ##
if (main.showDate) {
if (main.tooSmall) {
- dateLabelLeft.text = Qt.formatDate(main.currentTime, main.dateFormat);
+ dateLabelLeft.text = Qt.formatDate(main.currentTime, "dd.MM.yyyy");
} else {
dateLabel.text = Qt.formatDate(main.currentTime, main.dateFormat);
}

Grunt jshint disable Expected a conditional expression and instead saw an assignment

I am using grunt-contrib-jshint and it finds the following error in my JS file:
line 5 col 70 Expected a conditional expression and instead saw an assignment.
I know the reason of this error, but all I want is to disable it. Looking here it looks like I can either use no-cond-assign to 0 in my jshintrc or by adding -W084 : true in my options.
The problem is that the first solution ended up in a corrupted jshintrc and the second one does not solve the problem. Another option is to add -W022 : true (which solution I found in the comments) also does not work.
Use the ignore pragma to skip this line:
/* jshint ignore:start */
if(this = Infinity)
/* jshint ignore:end */
{
return;
}

How do I edit the VIM Omni Completion so that all CSS properties do not end in a colon?

I have been exploring some way in VIM to automatically append closing characters to a line of code. In my case it is CSS. I came across this tip http://vim.wikia.com/wiki/Automatically_append_closing_characters and tweaked the code it tells me to add to my .vimrc like so
inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}
so when I write
body
and then press { and ENTER in rapid succession what results is
body {
}
Note that the cursor will be indented and on the 2nd line so I will be ready to write code in that block.
Also I should mention that I also added the following to my .vimrc
inoremap :: :;<Left>
so that when I type : and : in rapid succession I will get :; with the cursor located in between the : and ;. This exactly where I want to be so I can start writing code right away.
I got that working fine but I quickly realized that the auto complete plug in that I installed (AutoComplPop VIM plug-in http://www.vim.org/scripts/script.php?script_id=1879) conflicts with the above .vimrc tweak.
So for example, if I start to write color I get the drop auto completion drop down menu of all options. The problem is that the option for color is actually color:.
You see it has a colon already added to it so when I select it, the colon is already there and then I have to manually add the closing ; character. This basically defeats the whole purpose of adding the auto appending closing character code to my .vimrc since in this case, it does not auto append the closing semicolon.
So how do I make a custom edit to VIM's Omni Completion so that all CSS properties do not end in a colon?
CSS auto completion options for VIM and came across AutoComplPop here http://www.vim.org/scripts/script.php?script_id=1879
Assuming you are on a UNIX-like system…
Copy
/usr/share/vim/vim7x/autoload/csscomplete.vim
to
~/.vim/autoload/csscomplete.vim
Find the loop that generates the list of properties, for me it's at line 92.
Remove the colon from the second parameter of the two add().
These lines:
call add(res, m . ':')
call add(res2, m . ':')
become:
call add(res, m)
call add(res2, m)
Save the file.
Also there are many plugins for "auto closing" pairs of characters. I use DelimitMate.
And the issue is not related to ACP at all.

Resources