Jasmine-spec-reporter: How to disable "Expected" description of a failed spec - jasmine-spec-reporter

Is it possible to configure the "jasmine-spec-reporter" to NOT display the Expected description of a failed spec.
For instance, in the output below, do not print the last row "Expected true to equal false." :
√ [ 1 ] May NOT enter the system when mandatory fields are empty
× [ 2 ] There is NO "Null Pointer Exception"
- Expected true to equal false.

With 3.1.0 version, you could use spec.displayErrorMessages and summary.displayErrorMessages options:
new SpecReporter({
spec: {
displayErrorMessages: false
},
summary: {
displayErrorMessages: false
}
})

Related

JQ if else then NULL Return

I'm trying to filter and output from JSON with jq.
The API will sometime return an object and sometime an array, I want to catch the result using an if statement and return empty string when the object/array is not available.
{
"result":
{
"entry": {
"id": "207579",
"title": "Realtek Bluetooth Mesh SDK on Linux\/Android Segmented Packet reference buffer overflow",
"summary": "A vulnerability, which was classified as critical, was found in Realtek Bluetooth Mesh SDK on Linux\/Android (the affected version unknown). This affects an unknown functionality of the component Segmented Packet Handler. There is no information about possible countermeasures known. It may be suggested to replace the affected object with an alternative product.",
"details": {
"affected": "A vulnerability, which was classified as critical, was found in Realtek Bluetooth Mesh SDK on Linux\/Android (the affected version unknown).",
"vulnerability": "The manipulation of the argument reference with an unknown input leads to a unknown weakness. CWE is classifying the issue as CWE-120. The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.",
"impact": "This is going to have an impact on confidentiality, integrity, and availability.",
"countermeasure": "There is no information about possible countermeasures known. It may be suggested to replace the affected object with an alternative product."
},
"timestamp": {
"create": "1661860801",
"change": "1661861110"
},
"changelog": [
"software_argument"
]
},
"software": {
"vendor": "Realtek",
"name": "Bluetooth Mesh SDK",
"platform": [
"Linux",
"Android"
],
"component": "Segmented Packet Handler",
"argument": "reference",
"cpe": [
"cpe:\/a:realtek:bluetooth_mesh_sdk"
],
"cpe23": [
"cpe:2.3:a:realtek:bluetooth_mesh_sdk:*:*:*:*:*:*:*:*"
]
}
}
}
Would also like to to use the statement globally for the whole array output so I can parse it to .csv and escape the null, since sofware name , can also contain an array or an object. Having a global if statement with simplify the syntax result and suppress the error with ?
The error i received from bash
jq -r '.result [] | [ "https://vuldb.com/?id." + .entry.id ,.software.vendor // "empty",(.software.name | if type!="array" then [.] | join (",") else . //"empty" end )?,.software.type // "empty",(.software.platform | if type!="array" then [] else . | join (",") //"empty" end )?] | #csv' > tst.csv
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7452 0 7393 100 59 4892 39 0:00:01 0:00:01 --:--:-- 4935
jq: error (at <stdin>:182): Cannot iterate over null (null)
What I have tried is the following code which i tried to demo https://jqplay.org/ which is incorrect syntax
.result [] |( if .[] == null then // "empty" else . end
| ,software.name // "empty" ,.software.platform |if type!="array" then [.] // "empty" else . | join (",") end)
Current output
[
[
"Bluetooth Mesh SDK"
],
"Linux,Android"
]
Desired outcome
[
"Bluetooth Mesh SDK",
"empty"
]
After fixing your input JSON, I think you can get the desired output by using the following JQ filter:
if (.result | type) == "array" then . else (.result |= [.]) end \
| .result[].software | [ .name, (.platform // [ "Empty" ] | join(",")) ]
Where
if (.result | type) == "array" then . else (.result |= [.]) end
Wraps .result in an array if type isn't array
.result[].software
Loops though the software in each .result obj
[ .name, (.platform // [ "Empty" ] | join(",")) ]
Create an array with .name and .platform (which is replaced by [ "Empty" ] when it doesn't exist. Then it's join()'d to a string
Outcome:
[
"Bluetooth Mesh SDK",
"Linux,Android"
]
Online demo
Or
[
"Bluetooth Mesh SDK",
"Empty
]
Online demo

HTTP 400 Error: size is too accurate. Smallest unit is 0.00000001

i am making a call to
authedClient.placeOrder(sellParams)
with params:
sellParams:any = {
'side': 'sell',
'product_id': 'BTC-USD',
'type': ‘market’,
’size’: 0.012613515
}
this throws error:
Error: HTTP 400 Error: size is too accurate. Smallest unit is 0.00000001
at Request._callback (/srv/node_modules/coinbase-pro/lib/clients/public.js:68:15)
at Request.self.callback (/srv/node_modules/request/request.js:185:22)
at emitTwo (events.js:126:13)
i am not sure why it fails. Please advise
It says that you should only place the size that is the increments of 0.00000001 (the base_increment below). While your size is at precision 9: 0.012613515, it is rejected.
Currently, I cannot find the base_increment in the /products endpoint, but in the status channel:
// Status Message
{
"type": "status",
"products": [
{
"id": "BTC-USD",
"base_currency": "BTC",
"quote_currency": "USD",
"base_min_size": "0.001",
"base_max_size": "70",
"base_increment": "0.00000001", // Here you go
"quote_increment": "0.01",
"display_name": "BTC/USD",
"status": "online",
"status_message": null,
"min_market_funds": "10",
"max_market_funds": "1000000",
"post_only": false,
"limit_only": false,
"cancel_only": false
}
],
...
}
I can add an update this, definitely the order float algebra is a little wonky and differs by exchange. For CB/CB Pro you'll want to get info on your base_increment for sell orders and quote_increment for buy orders, in string format, run a function like this:
def get_increments(ticker, auth_client):
products = auth_client.get_products()
for i in range(len(products)):
if products[i]['id'] == ticker:
base_incr = products[i]['base_increment']
quote_incr = products[i]['quote_increment']
return base_incr, quote_incr
i. Next, you'll want to utilize those increments to round down. I divide by the appropriate increment, use floor division by 1, then multiply by the same increment.
ii. To be safe, I get a decimal count again using string manipulation functions, and run something like round(qty, decimals). This cleans up the occasional lagging string of 9999999 or else 00000001.
iii. If you're looking to trade with 100% equity, use the funds argument in buy (quote asset value), and size argument in sell (base asset value).
Buy code looks something like:
decimals = int(str(quote_incr).find('1'))-int(str(quote_incr).find('.'))
quote_incr = float(quote_incr)
qty = (qty/quote_incr//1)*quote_incr
qty = str(round(qty,decimals))
auth_client.place_market_order(product_id=ticker, side='buy', funds=qty)
While sell code looks something like:
decimals = int(str(base_incr).find('1'))-int(str(base_incr).find('.'))
base_incr = float(base_incr_
qty = (qty/base_incr//1)*base_incr
qty = str(round(qty,decimals))
auth_client.place_market_order(product_id=ticker, side='buy', size=qty)

Why is JSONParsing failing in Codenameone

I am try to parse a son string into a PropertyBusinessObject. The string is in this format
[{
"_id": "5b632dfabba4456c000002b1",
"name": "General Comment",
"description": "Generic comments that can be applied to anything",
"label": "Comment",
"_created": "2018-08-02T16:14:50.504Z",
"comment_services": [],
"service_attributes": [
"5a5cb60d9d89946a0000721b",
"5a5e29ac9d89946a0000813a"
],
"category": [
"5b3222cb65fe554d00001585",
"5b32217665fe554d0000156f",
"5ca7939d0eaf051400001c5f",
"5b32214965fe554d0000156c"
],
"parent": [],
"providers": [],
"logo": ["5ae07365f2f6cd4100001397"]
}]
I end up with this error
[EDT] 0:1:28,595 - Expected true for key value while parsing JSON token at row: 1 column: 6 buffer:
[EDT] 0:1:28,595 - Exception: java.lang.ArrayIndexOutOfBoundsException - -1
[EDT] 0:1:28,597 - Exception during JSON parsing at row: 2 column: 3 buffer: [{
[EDT] 0:1:28,597 - Exception: java.lang.NullPointerException - null
at java.util.ArrayList.elementData(ArrayList.java:418)
at java.util.ArrayList.get(ArrayList.java:431)
at com.codename1.io.JSONParser.isStackHash(JSONParser.java:510)
at com.codename1.io.JSONParser.stringToken(JSONParser.java:631)
at com.codename1.io.JSONParser.parse(JSONParser.java:210)
at com.codename1.io.JSONParser.parseJSON(JSONParser.java:484)
at com.codename1.properties.PropertyIndex.loadJSONList(PropertyIndex.java:657)
There is nothing wrong with the format of the json as far as I can see and Ive validated with a json formater. Something in it however does not seem to be to the liking of JSONParser an I can't just pin point it.
This seems to be a bug in the parser, I pushed a fix for this here. It would be available next week.

Attribute Syntax for JSON query in check_json.pl

So, I'm trying to set up check_json.pl in NagiosXI to monitor some statistics. https://github.com/c-kr/check_json
I'm using the code with the modification I submitted in pull request #32, so line numbers reflect that code.
The json query returns something like this:
[
{
"total_bytes": 123456,
"customer_name": "customer1",
"customer_id": "1",
"indices": [
{
"total_bytes": 12345,
"index": "filename1"
},
{
"total_bytes": 45678,
"index": "filename2"
},
],
"total": "765.43gb"
},
{
"total_bytes": 123456,
"customer_name": "customer2",
"customer_id": "2",
"indices": [
{
"total_bytes": 12345,
"index": "filename1"
},
{
"total_bytes": 45678,
"index": "filename2"
},
],
"total": "765.43gb"
}
]
I'm trying to monitor the sized of specific files. so a check should look something like:
/path/to/check_json.pl -u https://path/to/my/json -a "SOMETHING" -p "SOMETHING"
...where I'm trying to figure out the SOMETHINGs so that I can monitor the total_bytes of filename1 in customer2 where I know the customer_id and index but not their position in the respective arrays.
I can monitor customer1's total bytes by using the string "[0]->{'total_bytes'}" but I need to be able to specify which customer and dig deeper into file name (known) and file size (stat to monitor) AND the working query only gives me the status (OK,WARNING, or CRITICAL). Adding -p all I get are errors....
The error with -p no matter how I've been able to phrase it is always:
Not a HASH reference at ./check_json.pl line 235.
Even when I can get a valid OK from the example "[0]->{'total_bytes'}", using that in -p still gives the same error.
Links pointing to documentation on the format to use would be very helpful. Examples in the README for the script or in the -h output are failing me here. Any ideas?
I really have no idea what your question is. I'm sure I'm not alone, hence the downvotes.
Once you have the decoded json, if you have a customer_id to search for, you can do:
my ($customer_info) = grep {$_->{customer_id} eq $customer_id} #$json_response;
Regarding the error on line 235, this looks odd:
foreach my $key ($np->opts->perfvars eq '*' ? map { "{$_}"} sort keys %$json_response : split(',', $np->opts->perfvars)) {
# ....................................... ^^^^^^^^^^^^^
$perf_value = $json_response->{$key};
if perfvars eq "*", you appear to be looking for $json_reponse->{"{total}"} for example. You might want to validate the user's input:
die "no such key in json data: '$key'\n" unless exists $json_response->{$key};
This entire business of stringifying the hash ref lookups just smells bad.
A better question would look like:
I have this JSON data. How do I get the sum of total_bytes for the customer with id 1?
See https://stackoverflow.com/help/mcve

React - atom eslint config

I used to use 'eslint-config-rallycoding' with .eslintrc as follows:
}
"extends": "rallycoding"
}
Recently I started having errors with it which I could not solve despite googling so I switched to 'esling-config-react'
}
"extends": "react"
}
Now eslint complains:
'Expected indentation of 4 spaces but found 2 (indent)'
I'm ok with 2. How can I change it accept 2?
Thanks
EDIT:
I checked the link suggested below and put the following in .eslintrc:
{
"extends": "react",
"rules": {
"indent": ["error": 2]
}
}
It results in the error in the console:
Configuration for rule "indent" is invalid:
Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '{ error: 2 }').
Error: /Users/wasteland/projects/react/shapes/.eslintrc:
Configuration for rule "indent" is invalid:
Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '{ error: 2 }').

Resources