Use of checkstyle.xml in diffplug/spotless - code-formatting

I have a checkstyle.xml file to check for formatting violations . Is there any way to provide checkstyle.xml as a input to diffplug/spotless formatter . Java8 is being used and spotless verison is 2.11.0 . If this is possible using spotless::apply we can remove all the style violations . Maven version is 3.6.3 . Currently google-java-format is being used .

Related

Why we use process.env in nestJs application to use the variables in .env file?

can anyone explain why we use the process.env to access the variables in the .env files in a nestJs application? I am unable to identify where the keyword process is mentioned in the whole application. If it is the standard procedure I am curious to know the reason behind it.
For example :
In main.ts I have the below reference :
.
.
.
const domainName = process.env.FRONTEND_DOMAIN;
.
.
.
In the .env file I have the variable below :
.
.
.
FRONTEND_DOMAIN = http://localhost:4200
Problem
The problem is I am unable to find the process keyword anywhere in the application even in the package.json file it is not imported from any packages but it is available in the package.lock.json.If anyone has an idea about how it works Kindly share it with me.Thanks in advance.
package.lock.json :
.
.
.
.
"process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="
},
.
.
.
.
this is not a nestjs stuff, it's all about nodejs & its ecosystem.
When we use some tool to load our env vars from some .env file (dotenv package is used by #nestjs/config under the hodd), it populates the process.env object. If your environment does not have any .env file, it won't populate anything, of course. But it also won't crash the app because this is often what we need, unless you have some validation step against those env. vars.
We usually want to use the .env file for development locally. But in production we usually inject those env. vars directly into the shell instead (eg: using export MY_ENV='123')

Checkstyle 8.41.1 throws exception when configuring a custom Google checkstyle.xml in IntelliJ 2021

I have upgraded to the latest Checkstyle plugin (8.41.1) using IntelliJ 2021.
I'm trying to configure a custom google checkstyle xml file, so I took the lates example from Github and tried to set it as config file to the checkstyle plug but I'm getting the following exception
com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - cannot initialize module JavadocMethod - Property 'accessModifiers' does not exist, please check the documentation
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:473)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:201)
at org.infernus.idea.checkstyle.service.cmd.OpCreateChecker.execute(OpCreateChecker.java:61)
...
...
If I'm setting the builtin Google check then it works.
Any idea?
I took the lates example from Github
This is the issue. You should be using the config that was built for the version of checkstyle you are using. You pulled in master's config which contains new features that have not been released.
See https://github.com/checkstyle/checkstyle/blob/49d1ea3835e017133ada46555d2214e017fc6fe2/src/main/resources/google_checks.xml

googlechecks.xml does not work in checkstyle5.6.1

I found googlechecks.xml from https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml . Imported it to checkstyle and have been trying to use this in checkstyle 5.6.1(Eclipse juno 4.2,JRE1.6). Problem occurs at FileExtension property.
I also want to add new rules in the xml file. Could anyone please let me know how to overcome this problem? That would be a great help and reapply appreciable.
Why are you trying to use so ancient checkstyle version (current is 7.1, last jdk7 based one is 6.19) and xml file from the latest master version?
Upgrade your checkstyle to at least 6.19 before using that file.
Or you can try to use older google checks, e.g. from the:
6.1.1 release: https://github.com/checkstyle/checkstyle/blob/c17bf06af9334ea1f6096868e591e6ee62774540/src/main/resources/google_checks.xml
5.8 release (when it first appeared): https://github.com/checkstyle/checkstyle/blob/8e4c7f743e5eebb38d039d15d8718d7b25587976/google_checks.xml

Kotlin - Error: Could not find or load main class _DefaultPackage

I followed the Kotlin tutorial for eclipse here : Getting Started With Eclipse Luna
However, I'm running into this error:
Error: Could not find or load main class _DefaultPackage
Anyone who knows to get around this?
This was a severe bug (KT-10221) in automatic generation of Launch Configuration in plugin version 0.4.0. It was fixed in 0.5.0 so the recommendend way to workaround is to update plugin.
The source of the problem was that the plugin used an old pattern for generating name of the class for main function that had been abandoned by Kotlin compiler.
It's possible to workaround it by editing launch configuration (Eclipse Menu -> Run -> Run Configurations...) by hand and changing Main class field in Java Application group. If the file is named hello.kt with no package directive, as it is described in tutorial, than corrected string should be HelloKt.
If file has name other.kt with package my.tutorial than the Main Class should contain my.tutorial.HelloKt. You can read more about it in the section Package-Level Functions of Calling Kotlin From Java page.
I have been getting the same issue. And after putting the right compiler output path, it got resolved.
Go to Project -> Project Compiler output :
In the text box, fill this:
[Absolute Path]/{Project Name}/out
In my case I was having this problem while trying to run the program using the Application Gradle plugin. The problem was in the mainClassName property using single quotes instead of double ones
This didn't work:
mainClassName = 'demo.HelloWorldKt'
With double quotes, it works:
mainClassName = "demo.HelloWorldKt"
For me it worked after I installed the correct JDK. I first had JDK 11 but the tutorial I did was with JDK 8 so after I installed this and set it in the "installed JREs" options it found the main class without having any "mainClassName" or any other option in the build.gradle file.
For me, it worked in a fresh eclipse workspace. Possibly, the Kotlin eclipse plugin is not playing well with other plugins (in my case, PyDev).
I'm creating a Kotlin Application with JavaFX and I had this issue until I went to:
Run > Run Configurations > Java Application > Common
I unticked "Allocate console" and it fixed the issue.

Protractor/Jasmine showing different versions - what am I doing wrong?

When I do this:
console.log('jasmine-version:' + jasmine.getEnv().versionString());
it prints: jasmine-version:1.3.1 revision 1354556913
When I run 'npm list jasmine-core' it prints:
server#0.0.1 /Users/xx/Desktop/workingDirectory
└── jasmine-core#2.1.3
Why is one showing 2.1.3 and another showing 1.3.1?
I don't seem to have the features in 2.1.3, so it's running 1.3.1. How do I fix this?
You have to specify that you want to use jasmine2 in the conf file. Please read the docs here: https://github.com/angular/protractor/blob/master/docs/jasmine-upgrade.md#in-your-conf-file.
Protractor supports both jasmine 1.3 and 2.x, and it's up to you to specify the version of jasmine you want to use. (Side note, 2.x is provided via jasmine-core, while 1.3 is provided via minijasminenode)
EDIT: another side note, protractor support for 2.x is not released until protractor 1.6 or if you use master
This is my issue https://github.com/angular/protractor/issues/362
Looks like Jasmine2 was only checked in a few days ago.