diff --git a/.github/workflows/ci-with-codeql.yml b/.github/workflows/ci-with-codeql.yml index 72474cb..e49270f 100644 --- a/.github/workflows/ci-with-codeql.yml +++ b/.github/workflows/ci-with-codeql.yml @@ -32,6 +32,7 @@ jobs: uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} + queries: +security-extended - name: Set up JDK 11 uses: actions/setup-java@v4 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b98da6d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Eficode + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/main/java/com/weather/app/WeatherApp.java b/src/main/java/com/weather/app/WeatherApp.java index 78fc099..3cb8a8d 100644 --- a/src/main/java/com/weather/app/WeatherApp.java +++ b/src/main/java/com/weather/app/WeatherApp.java @@ -10,9 +10,9 @@ * Main entry point for the Weather Application */ public class WeatherApp { - + private static final Logger LOGGER = Logger.getLogger(WeatherApp.class.getName()); - + // Initialize logging configuration static { try (InputStream is = WeatherApp.class.getClassLoader().getResourceAsStream("logging.properties")) { @@ -27,23 +27,23 @@ public class WeatherApp { e.printStackTrace(); } } - + // Flag to control System.exit behavior (for testing) private static boolean exitOnError = true; /** * Set whether the application should exit on error. * This method is primarily used for testing. - * + * * @param shouldExit true if the application should exit on error, false otherwise */ public static void setExitOnError(boolean shouldExit) { exitOnError = shouldExit; } - + /** * Exit the application with the given status code if exitOnError is true. - * + * * @param status the exit status code * @return true if the application would exit (for testing) */ @@ -70,7 +70,7 @@ public static void main(String[] args) { try { // Get API key from environment or config file String apiKey = ConfigUtil.getApiKey(); - + // Initialize services WeatherApiClient weatherApiClient = new OpenWeatherMapClient(apiKey); WeatherService weatherService = new WeatherService(weatherApiClient); @@ -78,12 +78,12 @@ public static void main(String[] args) { // Get and display weather data WeatherData weatherData = weatherService.getWeather(city); LOGGER.log(Level.FINE, weatherData.toString()); - + // Display weather data to the user System.out.println("Current Weather for " + city + ":"); System.out.println("-------------------------------------"); System.out.println(weatherData); - + } catch (ConfigUtil.ConfigException e) { LOGGER.log(Level.SEVERE, "Configuration error: " + e.getMessage(), e); LOGGER.log(Level.SEVERE,