Updated more sonarqube findings

This commit is contained in:
2022-06-26 12:04:42 -04:00
parent 4ec1346476
commit 51456c7533
3 changed files with 10 additions and 12 deletions

View File

@@ -1,10 +1,10 @@
//JavaClasses/src/main/java/mattrixwv/Stopwatch.java
//Matthew Ellison (Mattrixwv)
// Created: 03-01-19
//Modified: 07-28-20
//Modified: 06-26-22
//This file contains a class that is used to time the execution time of other programs
/*
Copyright (C) 2020 Matthew Ellison
Copyright (C) 2022 Matthew Ellison
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -71,27 +71,27 @@ public class Stopwatch{
stopTime = null;
}
//Returns the time in nanoseconds
public double getNano() throws InvalidResult{
public double getNano(){
return getTime().doubleValue();
}
//Returns the time in microseconds
public double getMicro() throws InvalidResult{
public double getMicro(){
return getTime().doubleValue() / 1000D;
}
//Returns the time in milliseconds
public double getMilli() throws InvalidResult{
public double getMilli(){
return getTime().doubleValue() / 1000000D;
}
//Returns the time in seconds
public double getSecond() throws InvalidResult{
public double getSecond(){
return getTime().doubleValue() / 1000000000D;
}
//Returns the time in minutes
public double getMinute() throws InvalidResult{
public double getMinute(){
return getTime().doubleValue() / 60000000000D;
}
//Returns the time in hours
public double getHour() throws InvalidResult{
public double getHour(){
return getTime().doubleValue() / 3600000000000D;
}
//Returns the time as a string at the 'best' resolution. (Goal is xxx.xxx)

View File

@@ -170,8 +170,6 @@ public class TestNumberAlgorithms{
@Test
public void testGetDivisors(){
Stopwatch timer = new Stopwatch();
timer.start();
//Test 1
List<Integer> correctAnswer = Arrays.asList(1, 2, 4, 5, 10, 20, 25, 50, 100);
Integer topNum = 100;
@@ -204,8 +202,6 @@ public class TestNumberAlgorithms{
bigTopNum = BigInteger.valueOf(6);
bigAnswer = NumberAlgorithms.getDivisors(bigTopNum);
assertEquals("getDivisors BigInteger 2 failed", bigCorrectAnswer, bigAnswer);
timer.stop();
System.out.println("timer = " + timer.toString());
}
@Test

View File

@@ -26,6 +26,7 @@ package mattrixwv;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
@@ -39,6 +40,7 @@ public class TestStopwatch{
Stopwatch timer = new Stopwatch();
timer.start();
timer.stop();
assertNotNull(timer.toString());
//If it gets to here without throwing an exception everything went well
}
@Test