ERROR: Malformed input or input contains unmappable characters - sonarqube

I am running the sonar scanner for my project with (-Dsonar.sourceEncoding=UTF-8) but I am getting the following error.
INFO: SonarQube Scanner 3.2.0.1227
INFO: SonarQube server 8.9.7
INFO: Default locale: "en_US", source code encoding: "UTF-8"
WARN: SonarScanner will require Java 11 to run, starting in SonarQube 9.x
...
ERROR: Error during SonarQube Scanner execution
ERROR: Malformed input or input contains unmappable characters: src/main/html/images/T??cnica.jpg
The word has a tilde.I have tried to exclude the .jpg files and the folder where this file is located but I still get the same error. Any solution?
Solution:
Inside the Jenkins container run the following commands to change the locale
apt-get update && apt-get install -y locales
sed -i '/es_ES.UTF-8/s/^# //g' /etc/locale.gen
locale-gen
update-locale LC_ALL="es_ES.UTF-8"

For me, adding this to the Dockerfile was enough:
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

Related

go application build with bazel can't link when running inside container

I am trying to containerize my application build, though, when running the build that uses bazel with bazel-gazelle inside a container I will get this error:
$ bazel run --spawn_strategy=local //:gazelle --verbose_failures
INFO: Analyzed target //:gazelle (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/workstation/.cache/bazel/_bazel_workstation/fb227af4c7b6aa39cc5b15d7fd9b737a/external/go_sdk/BUILD.bazel:43:15: GoToolchainBinary external/go_sdk/builder [for host] failed: (Exit 1): go failed: error executing command
(cd /home/workstation/.cache/bazel/_bazel_workstation/fb227af4c7b6aa39cc5b15d7fd9b737a/execroot/__main__ && \
exec env - \
GOROOT_FINAL=GOROOT \
external/go_sdk/bin/go tool link -o bazel-out/host/bin/external/go_sdk/builder bazel-out/host/bin/external/go_sdk/builder.a)
# Configuration: e0f1106e28100863b4221c55fca6feb935acec078da5376e291cf644e275dae5
# Execution platform: #local_config_platform//:host
/opt/go/pkg/tool/linux_amd64/link: mapping output file failed: invalid argument
Target //:gazelle failed to build
INFO: Elapsed time: 2.302s, Critical Path: 0.35s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
I tried to run it standalone:
$ /home/workstation/.cache/bazel/_bazel_workstation/fb227af4c7b6aa39cc5b15d7fd9b737a/external/go_sdk/bin/go tool link -o bazel-out/host/bin/external/go_sdk/builder bazel-out/host/bin/external/go_sdk/builder.a
/opt/go/pkg/tool/linux_amd64/link: mapping output file failed: invalid argument
and still got no success.
Never had this kind of link problem and the linker don't provide much more information. Tried to install all packages I could think of and still no luck.
For context:
Running Ubuntu 20.04 LTS
Docker 20.10.9
Bazel 4.2.2
Rules GO v0.31.0
Bazel Gazelle v0.25.0
Also tried to run it with the strace, though I don't think I am skilled enough to find meaningful information from the tool output.
#edit
For more context:
e$ /home/workstation/.cache/bazel/_bazel_workstation/fb227af4c7b6aa39cc5b15d7fd9b737a/external/go_sdk/bin/go tool link -v -o bazel-out/host/bin/external/go_sdk/builder bazel-out/host/bin/external/go_sdk/builder.a
HEADER = -H5 -T0x401000 -R0x1000
searching for runtime.a in /opt/go/pkg/linux_amd64/runtime.a
/opt/go/pkg/tool/linux_amd64/link: mapping output file failed: invalid argument

Slather command failed to execute. Xcode, Jenkins, Sonar qube

+ slather coverage --binary-basename Project --input-format profdata -i '.*Tests.*' --cobertura-xml --output-directory sonar-reports --workspace Project.xcworkspace --scheme ProjectTests Project.xcodeproj
ERROR: Unrecognised option '--workspace'
See: 'slather coverage --help'
+ returnValue=1
+ set +x
ERROR - Command 'slather coverage --binary-basename Project --input-format profdata -i .*Tests.* --cobertura-xml --output-directory sonar-reports --workspace Project.xcworkspace --scheme ProjectTests Project.xcodeproj'
failed with error code: 1
Parameters which I have specified as follows.
workspaceFile=''; readParameter workspaceFile 'sonar.swift.workspace'
slatherCmd+=( --input-format profdata $excludedCommandLineFlags --cobertura-xml --output-directory sonar-reports)
if [[ ! -z "$workspaceFile" ]]; then
echo "$workspaceFile"
slatherCmd+=( --workspace $workspaceFile)
In the sonar project.properties I have mentioned the workspace.
Getting this error while working with Xcode, Jenkins, and Sonar Qube.
What could be wrong with the command? Did I miss something?
Slather is installed in mac, is there something that I have to set up before running Xcode?
I tried installing Slather but I don't know why it is showing that.

Coverall module fails to parse string(s)

I'm testing my application with mocha along with istanbul.
For coverage and testing i'm using the following entries in my package.json
"test:integration": "cross-env NODE_ENV=test mocha --timeout 20000 src/api/tests/integration",
"coverage": "nyc report --reporter=text-lcov | coveralls",
The test passes, but when doing yarn coverage i'm getting an error
$ nyc report --reporter=text-lcov | coveralls
[error] "2018-08-04T21:25:57.261Z" 'error from lcovParse: ' 'Failed to parse string'
[error] "2018-08-04T21:25:57.263Z" 'input: ' ''
[error] "2018-08-04T21:25:57.263Z" 'error from convertLcovToCoveralls'
C:\Users\Mikk\Documents\GitHub\backend\node_modules\coveralls\bin\coveralls.js:18
throw err;
^
Failed to parse string
Any ideas? I even tried to reinstall the node modules, but that doesn't seem to fix anything.
I had the same set up in my package.json file and the same issues earlier today but I fixed it by refreshing my repo attached to Coveralls.io
After refreshing, I restarted build on Travis CI and it worked.
Ensure you have the following in your project root dir
.coveralls.yml -- It should contain repo_token if you're using a public repo

Blame Error during SonarQube Scanner execution

I am using sonarqube-6.0 and i tried with a sample example to run with sonar-scanner
i am getting the blame ERROR when ever I run any project in sonar-scanner
The file Conf in sonar-scanner configuration is vi sonar-scanner.properties
#
# must be unique in a given SonarQube instance
sonar.projectKey=SonarSource-sonar-examples-8051d9d
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=java-maven-simple
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=/Users/kingslee/work/software/projects/sonar-scanner-2.8/bin/sonar-examples
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
~
When i run command ./sonar-scanner these are the error which i get frequently
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to blame file sonar-examples/plugins/java-custom-rules/src/main/java/org/sonar/samples/java/MyJavaFileCheckRegistrar.java
at org.sonarsource.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:128)
at org.sonarsource.scm.git.JGitBlameCommand.access$000(JGitBlameCommand.java:44)
at org.sonarsource.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:112)
at org.sonarsource.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:109)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.eclipse.jgit.internal.storage.file.UnpackedObjectCache$Table.index(UnpackedObjectCache.java:146)
at org.eclipse.jgit.internal.storage.file.UnpackedObjectCache$Table.contains(UnpackedObjectCache.java:109)
at org.eclipse.jgit.internal.storage.file.UnpackedObjectCache.isUnpacked(UnpackedObjectCache.java:64)
at org.eclipse.jgit.internal.storage.file.ObjectDirectory.openObject(ObjectDirectory.java:376)
at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:142)
at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:226)
at org.eclipse.jgit.blame.BlameGenerator.push(BlameGenerator.java:317)
at org.eclipse.jgit.api.BlameCommand.call(BlameCommand.java:216)
at org.sonarsource.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:126)
... 7 more
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

Sonar - Fail to request server version | HTTP Status 404 /

With each run done by console or by Jenkins throws me the following error:
SonarQube Runner 2.4
Java 1.8.0_51 Oracle Corporation (32-bit)
Linux 2.6.32-504.30.3.el6.i686 i386
INFO: Runner configuration file: /usr/local/sonar-runner/conf/sonar-runner.properties
INFO: Project configuration file: /opt/apps/php-sonar-runner/sonar-project.properties
INFO: Default locale: "es_ES", source code encoding: "UTF-8"
INFO: Work directory: /opt/apps/php-sonar-runner/./.sonar
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 0.042s
Final Memory: 0M/28M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Fail to request server version
ERROR: Caused by: Status returned by url : 'http://xxx.xxx.xx.xxx:9000/api/server/version' is invalid : 404
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Open the URL 'http://xxx.xxx.xx.xxx:9000/api/server/version' in a browser, see if it gives you a 404 error. If so, you need to find the right path to Sonar root on the remote server, maybe 'http://xxx.xxx.xx.xxx:9000/sonar/'?
When you have the full URL of Sonar, update the sonar.host.url property in your pom accordingly. See full documentation for more details.
Check the value of sonar.web.context = /myPath maybe you have some path and you configure other path in your url at your jenkis, tfs, etc. That is the reason you get an 404 error.
In your example you should not have that value configurated or without a value.
'http://xxx.xxx.xx.xxx:9000/myPath/api/server/version
In your sonar-runner.properties file
define #--- Default SonarQube sever as give below
sonar.host.url=http://localhost:9000/sonar
Also cross check in sonar.properties file i.e
sonar.web.port=9000
sonar.web.host=127.0.0.1
sonar.web.context=/sonar

Resources