How to properly run SpotBugs on a Scala project - scala

I'm trying to get SpotBugs run on Scala project using the SpotBugs CLI.
I installed the CLI like this:
$ curl -L -o /tmp/spotbugs-4.0.3.tgz https://github.com/spotbugs/spotbugs/releases/download/4.0.3/spotbugs-4.0.3.tgz
$ gunzip -c /tmp/spotbugs-4.0.3.tgz | tar xvf - -C /tmp
Then I run it like this
$ time java -jar /tmp/spotbugs-4.0.3/lib/spotbugs.jar -textui -xml:withMessages -html -output target/scala-2.11/spotbugs-report.html vad/target/scala-2.11/projectx-SNAPSHOT-assembly.jar
^Cjava -jar /tmp/spotbugs-4.0.3/lib/spotbugs.jar -textui -xml:withMessages -htm 2462.79s user 135.67s system 130% cpu 33:16.98 total
You can notice that it took more than 30mn without even have finished, I had to halt it.
It obviously seems that SpotBugs is not running properly here, so what am I doing wrong here?

Related

Perlbrew fails to install new perl version

I'm attempting to install a new perl version with perlbrew:
perlbrew install perl-5.34.1
but this produces the error:
Fetching perl 5.34.1 as /home/703404669/perl5/perlbrew/dists/perl-5.34.1.tar.gz
Download https://cpan.metacpan.org/authors/id/S/SH/SHAY/perl-5.34.1.tar.gz to /home/703404669/perl5/perlbrew/dists/perl-5.34.1.tar.gz
ERROR: Failed to download https://cpan.metacpan.org/authors/id/S/SH/SHAY/perl-5.34.1.tar.gz
ERROR: Failed to execute the command
curl --silent --location --fail -o /home/703404669/perl5/perlbrew/dists/perl-5.34.1.tar.gz https://cpan.metacpan.org/authors/id/S/SH/SHAY/perl-5.34.1.tar.gz
Reason:
5888
which I'm unable to find on Google searches.
I know that there isn't any typo, because when I intentionally write something wrong, I get a different error.
I have no idea why this is happening, nor to fix it.
EDIT:
the command
curl --location https://cpan.metacpan.org/authors/id/S/SH/SHAY/perl-5.34.1.tar.gz > /dev/null
outputs
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 17.3M 100 17.3M 0 0 68.5M 0 --:--:-- --:--:-- --:--:-- 68.5M
How can I install a perl version with perlbrew?
5888 is 0x1700. This could be $? for a program that used exit(0x17), which is to say exit(23). curl uses that exit code when
23 Write error. Curl couldn't write data to a local filesystem or similar.
Sounds like it can't write to /home/703404669/perl5/perlbrew/dists/perl-5.34.1.tar.gz.
If the directory doesn't exist, maybe you didn't properly install perlbrew.
Ways to install perlbrew:
\curl -L https://install.perlbrew.pl | bash
\wget -O - https://install.perlbrew.pl | bash
\fetch -o- https://install.perlbrew.pl | sh
sudo cpan App::perlbrew
perlbrew init
You also need to place a command in your shell's interactive startup script as instructed.
Or maybe you don't have enough disk space. Did you mean to install perlbrew somewhere other than /home/703404669/perl5/perlbrew?
The default perlbrew root directory is ~/perl5/perlbrew, which can be changed by setting PERLBREW_ROOT environment variable before the installation and initialization.
In my case the problem was that it would not create the destination folder for that download. So what fixed it for me was:
mkdir $HOME/perl5/perlbrew/dists -p
In the above case just:
mkdir -p /home/703404669/perl5/perlbrew/dists

How do I send a command to a remote system via ssh with concourse

I have the need to start a java rest server with concourse that lives on an Ubuntu 18.04 machine. The version of concourse my company uses is 5.5.11. The server code is written in Java, so a simple java -jar <uber.jar> suffices from the command line (see below). In production, I will not have this simple luxury, hence my question.
I have an scp command working that copies the .jar from concourse to the target Ubuntu machine:
scp -i /tmp/key.p8 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ./${NEW_DIR}/${ARTIFACT_NAME}.${ARTIFACT_FILE_TYPE} ${SRV_ACCOUNT_USER}#${JAVA_VM_HOST}:/var/www
Note that my private key is passed with -i and I can confirm that is working.
I followed this other SO Q&A that seemed to be promising: Getting ssh to execute a command in the background on target machine
, but after trying a few permutations of the suggested solution and other answers, I still don't have my rest service kicked off.
I've tried a few permutations of this line in my concourse script:
ssh -f -i /tmp/pvt_key1.p8 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${SRV_ACCOUNT_USER}#${JAVA_VM_HOST} "bash -c 'nohup java -jar /var/www/${ARTIFACT_NAME}.${ARTIFACT_FILE_TYPE} -c \"/opt/testcerts/clientkeystore\" -w \"password\" > /dev/null 2>&1 &'"
I've tried with and without the -f and -t switches in ssh, with and without the file stream redirection, with and without nohup and the Linux background ('&') command and various ways to escape the quotes.
At the bash prompt, this line successfully starts my server. The two switches are needed to point to the certificate and provide the password:
java -jar rest-service.jar -c "/opt/certificates/clientkeystore" -w "password"
I really think this is possible to do in Concourse, but I'm stuck at this point.
After a lot of trial an error, it seems I needed to do this:
ssh -f -i /tmp/pvt_key1.p8 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${SRV_ACCOUNT_USER}#${JAVA_VM_HOST} "bash -c 'sudo java -jar /var/www/${ARTIFACT_NAME}.${ARTIFACT_FILE_TYPE} -c \"/path/to/my/certificate\" -w \"password\" > /var/www/log.txt 2>&1 &'"
The key was I was missing the 'sudo' portion of the command. Using nohup as opposed to putting in a Linux bash background indicator ('&') seems to give me an error in the pipeline. This works for me, but others are welcome to post responses with better answers or methods that might be a better practice.

rkt/image building: acbuild run instructions "ignored"

I'm experiencing unexpected behavior using acbuild run. To get used to rkt the idea was to start with a CentOS7 based container running a SSH host. The bare CentOS 7 container referenced below as centos7.aci was created on a up-to-date CentOS7 install using the instructions given here.
The script used to build the SSHd ACI is
#! /bin/bash
acbuild begin ./centos7.aci
acbuild run -- yum install -y openssh-server
acbuild run -- mkdir /var/run/sshd
acbuild run -- sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
acbuild run -- sed 's#session\s*required\s*pam_loginuid.so#session optional pam_loginuid.so#g' -i /etc/pam.d/sshd
acbuild run -- ssh-keygen -A -C "" -N "" -q
acbuild run -- echo 'root:screencast' | chpasswd
acbuild set-name centos7-sshd
acbuild set-exec -- /usr/sbin/sshd -D
acbuild port add ssh tcp 22
acbuild write --overwrite centos7-sshd.aci
acbuild end
When it's spinned up using rkt run --insecure-options=image ./centos7-sshd.aci
the server runs but connection attempts fail because the password is not accepted. If I use rkt enter to get into the running container and re-run echo 'root:screencast' | chpasswd inside, I can login. So that acbuild run instruction has just not worked for some reason... To test a bit more, I replaced it by
acbuild run -- mkdir ~/.ssh
acbuild run -- echo "<rkt host SSH public key>“ >> ~/.ssh/authorized_keys
to enable key based instead of password login. It doesn't work: the key is refused. The reason is obvious once you look into the container: there's no authorized_keys file in ~/.ssh/. If I add a
acbuild run -- touch ~/.ssh/authorized_keys instruction before the key appending attempt, the file is created but it's still empty. So again a acbuild run instruction didn't work - without error notice. May it be related to the fact that both „ignored“ instructions use operators like >> and | ? All commands shown in the examples I've seen don't use any such operators yet the docs don't mention anything and a Google search doesn't help either. In dockerfile RUN instructions they also work fine... what is going wrong here?
P.S.: I tried to use the chroot instead of the default systemd-nspawn engine in the „ignored“ acbuild run instructions => same results
P.P.S.: there's no acbuild tag yet on StackOverflow so I had to tag this as rkt - could somebody with enough reputation create one please? Thx
Ok, I understood what happens using the the acbuild run --debug option.
When
acbuild run -- echo 'root:screencast' | chpasswd
gets executed it returns Running: [echo root:screencast] , the pipe is executed on the host machine. To get the intended result it should be
acbuild run -- /bin/sh -c "echo 'root:screencast' | chpasswd"
or in generic form
acbuild run -- /bin/sh -c "<cmd with pipes>"
as explained here

SBT incremental compilation with WebJars inside Docker

I am working on Play! application with Angular 2 and webjars dependencies.
SBT play plugin and typescript plugin. I use incremental compilation, but it takes great amount of time on each recompilation. I set "sbt-optimizer" to check which tasks are longest one. And i see that on each recompilation WebJars are taking almost all the recompile time. I can't imagine why he needs to do something with static files after first compilation. But even if i change scala file or twirl template, it does not matter again all webjars.
UPD:
If i run on machine without Docker then speed is normal - recompile take few seconds.
Inside Docker - 200sec+.
Compilation messages without docker - 2s, inside docker - 13s.
Operations on screen without docker 10-300ms inside docker 500-60000ms.
UPD:
Adding my docker file
FROM openjdk:8
ENV SCALA_VERSION=2.12.1
ENV SBT_VERSION=0.13.13
ENV NODEJS_VERSION=6.10.0
# Install sbt
RUN cd /tmp && \
wget https://dl.bintray.com/sbt/native-packages/sbt/$SBT_VERSION/sbt-$SBT_VERSION.zip && \
unzip sbt-$SBT_VERSION.zip -d /usr/local && \
rm sbt-$SBT_VERSION.zip
#install nodejs for web jars
RUN cd /tmp && \
wget https://nodejs.org/dist/v$NODEJS_VERSION/node-v$NODEJS_VERSION-linux-x64.tar.xz && \
tar -C /usr/local --strip-components 1 -xJf node-v$NODEJS_VERSION-linux-x64.tar.xz &&
rm node-v$NODEJS_VERSION-linux-x64.tar.xz
Here is printout from optimizer:
May be i missed something, or someone had such problems, why SBT do that each time, and how can i prevent this?
Thank you
If you are running a mounted volume on Docker for Mac, you're probably hitting this issue with performance of mounted volumes.

How to install Grafana on Mac

I tied the following steps
cd $GOPATH/src/github.com/grafana/grafana
go run build.go setup
I got the following
Version: 2.5.0-pre1, Linux Version: 2.5.0, Package Iteration: pre1
go get -v github.com/tools/godep
github.com/tools/godep (download)
github.com/tools/godep/Godeps/_workspace/src/github.com/kr/fs
github.com/tools/godep/Godeps/_workspace/src/github.com/pmezard/go-difflib/difflib
github.com/tools/godep/Godeps/_workspace/src/golang.org/x/tools/go/vcs
github.com/tools/godep
go get -v github.com/blang/semver
github.com/blang/semver (download)
github.com/blang/semver
go get -v github.com/mattn/go-sqlite3
go install -v github.com/mattn/go-sqlite3
then i executed
$GOPATH/bin/godep restore
i got no putput but command got executed
then i ran the command
go run build.go build
Version: 2.5.0-pre1, Linux Version: 2.5.0, Package Iteration: pre1
rm -r bin
rm -r Godeps/_workspace/pkg
rm -r Godeps/_workspace/bin
rm -r dist
rm -r tmp
rm -r /Users/skhare/sk/go/pkg/darwin_amd64/github.com/grafana
rm -r ./bin/grafana-server
rm -r ./bin/grafana-server.md5
GOPATH=/Users/skhare/sk/go/src/github.com/grafana/grafana/Godeps/_workspace:/Users/skhare/sk/go
go build -ldflags -w -X main.version '2.5.0-pre1' -X main.commit 'v2.1.2+394- gfb767f5' -X main.buildstamp 1442671169 -o ./bin/grafana-server .
# github.com/grafana/grafana
link: warning: option -X main.version 2.5.0-pre1 may not work in future releases; use -X main.version=2.5.0-pre1
link: warning: option -X main.commit v2.1.2+394-gfb767f5 may not work in future releases; use -X main.commit=v2.1.2+394-gfb767f5
link: warning: option -X main.buildstamp 1442671169 may not work in future releases; use -X main.buildstamp=1442671169
then i executed
npm install
i had to install npm
>npm install -g grunt-cli
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
grunt-cli#0.1.13 /usr/local/lib/node_modules/grunt-cli
├── resolve#0.3.1
├── nopt#1.0.10 (abbrev#1.0.7)
└── findup-sync#0.1.3 (lodash#2.4.2, glob#3.2.11)
>grunt
Running "jscs:src" (jscs) task
>> 156 files without code style errors.
Running "jshint:source" (jshint) task
✔ No problems
Running "jshint:tests" (jshint) task
✔ No problems
Running "tslint:source" (tslint) task
>> 11 files lint free.
Running "clean:gen" (clean) task
Cleaning public_gen...OK
Running "copy:public_to_gen" (copy) task
Created 122 directories, copied 553 files
Running "less:src" (less) task
File public_gen/css/bootstrap.dark.min.css created.
File public_gen/css/bootstrap.light.min.css created.
File public_gen/css/bootstrap-responsive.min.css created.
Running "concat:cssDark" (concat) task
File public_gen/css/grafana.dark.min.css created.
Running "concat:cssLight" (concat) task
File public_gen/css/grafana.light.min.css created.
Running "typescript:build" (typescript) task
42 files created. js: 14 files, map: 14 files, declaration: 14 files (968ms)
Done, without errors.
>go get github.com/Unknwon/bra
the above command did not give any output, nor an error message
bra run
it says -bash: bra: command not found
i tried to look for the resolution, but i could not find it. Please help
Recompile backend on source change
To rebuild on source change (requires that you executed godep restore)
go get github.com/Unknwon/bra
bra run
Running Grafana Locally
You can run a local instance of Grafana by running:
./bin/grafana-server
You must have missed this step!
go get github.com/Unknwon/bra
You can install Grafana using home brew.
brew update
brew install grafana
This sounds like an issue where Go is just being installed to build something else (for me, it was Grafana). In which case $GOPATH/bin is not in your PATH. $GOPATH/bin/bra should work. It did for me.
I suggest you installing Grafana inside Docker. If you install Docker for Mac, the GUI (Kitematic) will allow you to install grafana as easily as one click. You will just need to create a new container with "+ New" button, search grafana through the exisiting image lists and click "Create"
Docker will download grafana and it will appear in the left sidebar: