Kotlin alternative for #SuppressWarnings("WeakerAccess") - kotlin

Is there alternative for #SuppressWarnings("WeakerAccess") in kotlin?
I've tried #Suppress("WeakerAccess") but no luck. It's pretty annoying to see "Function xxx could be private" when developing a library.

Write test code in src/test/kotlin that makes use of your functions.

Related

How to call validate.js and use it in feature file (to verify the response)?

How to call validate.js and use it in feature file (to verify a specific part of the response)?
I am trying to use https://github.com/validatorjs/validator.js which is a library with some awesome validators out-of-the-box.
While reading the Karate documentation there is a way to read / call and read .js files, so I taught there has to be a way to do this. https://intuit.github.io/karate/#schema-validation
I gotten this far but: ReferenceError: "isNumeric" is not defined in at line number 1
var validator = require('validator');
* def isNumeric = validator.isNumeric ;
In a scenario:
And match each response/list/costs/numberX == '#? isNumeric(_)'
I feel I am really close...
Unfortunately as of now Karate supports only ES5 (via Nashorn) and also does not support JS "module" concepts such as the import or require keywords.
Personally I think this is a good thing, the more JS you use, the more unmaintainable your scripts become. And there is no good way to debug. Note that Karate has syntax to do "functional style" loops and transformations.
Also I have found that in most of the cases where you think JS is needed, Karate's built-in schema validation is sufficient or a better choice.
That said, we hope that when we switch to Graal (proposed, and a must for Java 13+) we will be able to use ES6+ and I am personally looking forward to the arrow notation for functions.

SonarQube: How to suppress a warning in Kotlin code

I'm using SQ 7.3-alpha1 with sonar-kotlin-plugin-1.0.1.965.jar. However, I cannot deactivate a special warning inside my Kotlin code for repositories in Spring Data where I need an "_" in a method name.
I tried both //NOSONAR and #Suppress("kotlin:S100") and #SuppressWarnings("kotlin:S100"). Any hint is appreciated.
You're not able to deactivate that issue because none of the mechanisms you're trying to use have been implemented for Kotlin.
Instead, you'll have to do this from the UI side.
Great news, https://jira.sonarsource.com/browse/SONARSLANG-373 is fixed in version 1.6 of Sonarslang. So an update to that version might improve the situation. I’ve not tested it yet, hence the cautious wording.

Using StatePrinter from VB rather than C# to implement ToString

I'm trying to follow the promising suggestion posted here to try StatePrinter as a shortcut to rolling my own ToString methods. I agree with the OP that it is a shame that VS still can't generate this method for me.
I've got a fairly large project, in VS2015 (Community Edition), with both VB and C# code. I added the current stable version of StatePrinter using NuGet.
I can make the example code from the SO answer work fine in my C# code but when I do what I think is the equivalent in my VB code:
Private Shared sp As StatePrinter.Stateprinter = New StatePrinter.Stateprinter
Public Overrides Function ToString() As String
Return sp.PrintObject(Me)
End Function
I just get the compiler error
'Stateprinter' is ambiguous in the namespace 'StatePrinter'
There IS another constructor, StatePrinter (note difference in capitalization only) which is deprecated and, in any case, generates the same error message.
I'm led to the unfortunate conclusions that
VB in VS2015 is acting as if it is case insensitive. Can that be true?
No one else is using StatePrinter from VB.
Can anyone provide any suggestions on how to use StatePrinter from VB? I'm willing to believe I'm making some rather brain-dead mistake in converting the C# example to VB.
It is near impossible to use this directly in VB and get around the ambiguous name issue. You could write a class library wrapper in C# that doesn't expose this mismatch (that is, it has an internal StatePrinter object and exposes constructors that are PascalCased the same.
Another option would be to use reflection in the VB project to get around the case insensitivity.
You could also create a GitHub issue. Or, be a contributor to the project and create a suggested fix for it. :)
As soon as I got done writing #1 in the question above, I was able to figure out how to search for the answer to that bit.
Yes, VB is case insensitive, at least, as far as it needs to be in this case:
See the rather nice writeup here:
https://stackoverflow.com/a/2301980/165164
So, we're left with the rather plaintive: is no one else using StatePrinter from VB?

How to develop API with Hapi.js in coffeescript

I'm new to hapi.js and I would try test it out. Is it possible to develop with Hapi.js and coffeescript? Could you supply some example on how to setup hapi.js with coffeescript.
I thought the same approach would be useful. From CoffeeScript.org:
The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable and pretty-printed, will work in every JavaScript runtime, and tends to run as fast or faster than the equivalent handwritten JavaScript.
If you know CoffeeScript, then you should be able to translate all examples into CoffeeScript by yourself. Else, you should learn CoffeeScript.
Copy and paste any example code into http://js2.coffee and it will show you how it may look like in coffeescript.
And yes you could easily use coffeescript also with hapi like:
Hapi = require 'hapi'
server = new Hapi.Server()
server.connection
port: 3000
server.start ->
console.log 'Server running at:', server.info.uri

"Guess" method arguments in IntelliJ IDEA

Eclipse has a feature, where it "guesses" arguments for a method call, based on types (and probably variable names?). Is there an equivalent in IntelliJ? I know Smart Complete should be capable of completing multiple arguments, but it doesn't work as good (especially when there is more than one String argument for example).
EDIT: It's called "Insered best guessed arguments" in Eclipse.
There is Ctrl+Shift+Space (Smart-Type, I think), but as of this writing, it's crap and doesn't go the whole hog.
Despite being an Eclipse fan, I've always openly acknowledge that if Eclipse can do it, IntelliJ can probably do it better... not this time, how dissappointing q(`_`!)p
IDEA doesn't support it, see the related feature request.
Try
(Ctrl+P) for Windows/Linux
Or
(Cmd+P) for OS X
this lists you the parameters for a method.
If you can accept a very basic low tech version of this, you could try this Gist
https://gist.github.com/kontext-e/f68c6a1b90dd862afb5d
for IDEAs LivePlugin.
Please ping me if there is some interest that I should make a real plugin out of this.