How Do You Troubleshoot the sonar-scanner CLI Not Working?

Problem scenario
You run sonar-scanner from the command prompt, but you receive an error. The error looks like one of the following:

“Task ‘-x’ does not exist. Please use ‘list’ task to see all available tasks”

“You must define the folowing mandatory properties for ‘Unknown’: sonar.projectKey, sonar.sources”

What should you do to get sonar-scanner to work?

Solution
Run the sonar-scanner command from a local directory where you have sonar-project.properties.

How Do You Get Python to Compute How Long Something Took?

Problem scenario
You want to check the runtime duration of a section of Python code. How do you compute the amount of time something took in Python?

Solution
Write a program like this:

import datetime, time
t1 = datetime.datetime.now()
time.sleep(5) # replace this line with the section of code you want to time
t2 = datetime.datetime.now()
t3 = t2 – t1
print(“Time format is in hours:minutes:seconds:seconds_decimals”)
print(t3) …

How Do You Solve This Problem “Error: Could not find or load main class org.apache.hadoop.util.VersionInfo”

Problem scenario
You run “hadoop version” but you receive this message “Error: Could not find or load main class org.apache.hadoop.util.VersionInfo”. What do you do?

Possible Solution #1
Use “sudo ” before the “hadoop version” command.

Possible Solution #2
Use “sudo -i ” before the “hadoop version” command.

Possible Solution #3
Use a different user.

How Do You Get Hadoop Commands to Work from Any Directory without Using the Full Path?

Problem scenario
Hadoop is installed on Linux. But hadoop version and other hadoop commands are not working. What should you do?

Solution
Find the hadoop executable in a directory named bin. It is often “/usr/local/hadoop/bin/hadoop”. Ultimately you need to find the directory that houses this “bin.” has a subdirectory with “bin” and “hadoop” inside, run these two commands:

sudo find / -name hadoop -type f
whereis hadoop

Run these commands interactively where “/usr/local/hadoop” is the directory that is the parent of the subdirectory named “bin” that is the parent of the hadoop executable.

How Do You Troubleshoot the Go Programming Error ‘non-name m1[“foo”] on left side of :=’?

Problem scenario
You are running a Go program. You see this message about “command-line-arguments”:

non-name m1[“foo”] on left side of :=

What should you do?

Possible Solution
Can you try to use “=” instead of “:=”? This may fix your problem.

The := is a variable declaration and an assignment. If your map has been declared,

How Do You Use a Function in Golang?

Problem scenario
You are trying to learn to program in Go. How do you use a function?

Solution
Prerequisite
This assumes that you have installed Golang; if you need assistance with this, see this posting.

Procedures
1. Create a file called b.go with this as the content:

package main

import “fmt”

// ContintFunction will display a message
func ContintFunction() {
fmt.Println(“Hello from Continual Integration”)
}

func main() {
ContintFunction()
}

2.

How Do You Find out What Packages You Can Install That Are Related to a Certain Category when Using Ubuntu Linux?

Problem scenario
You want to find what Java packages are available on the configured repositories of the Linux server you are using. What do you do?

Solution
Run a command like this: apt-cache search java

You can replace “java” with a word of the package you want to install.

If you want to learn more about the package and have its exact name,