[gnome-clocks/bilelmoussaoui/ci/linter] Linter: fix various linting issues



commit ca7cdd4fc95ec705ac62b92f871ba685fe8380cc
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Tue Jan 28 17:29:01 2020 +0100

    Linter: fix various linting issues

 src/alarm.vala           |  2 +-
 src/application.vala     | 24 ++++++++++++------------
 src/geocoding.vala       |  8 ++++----
 src/headerbar.vala       |  4 ++--
 src/search-provider.vala | 14 +++++++-------
 src/stopwatch.vala       |  6 +++---
 src/timer.vala           | 18 +++++++++---------
 src/utils.vala           | 32 ++++++++++++++++----------------
 src/window.vala          | 24 ++++++++++++------------
 9 files changed, 66 insertions(+), 66 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index 2ea377a..d819c31 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -145,7 +145,7 @@ private class Item : Object, ContentItem {
         } else {
             // Alarm with at least one day set.
             // Find the next possible day for ringing
-            while (dt.compare (now) <= 0 || ! days.get ((Utils.Weekdays.Day) (dt.get_day_of_week () -1))) {
+            while (dt.compare (now) <= 0 || ! days.get ((Utils.Weekdays.Day) (dt.get_day_of_week () - 1))) {
                 dt = dt.add_days (1);
             }
         }
diff --git a/src/application.vala b/src/application.vala
index b24af57..25b5e67 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -19,12 +19,12 @@
 namespace Clocks {
 
 public class Application : Gtk.Application {
-    const OptionEntry[] option_entries = {
+    const OptionEntry[] OPTION_ENTRIES = {
         { "version", 'v', 0, OptionArg.NONE, null, N_("Print version information and exit"), null },
         { null }
     };
 
-    const GLib.ActionEntry[] action_entries = {
+    const GLib.ActionEntry[] ACTION_ENTRIES = {
         { "stop-alarm", null, "s" },
         { "snooze-alarm", null, "s" },
         { "quit", on_quit_activate },
@@ -41,8 +41,8 @@ public class Application : Gtk.Application {
     private void ensure_window () {
         if (window == null) {
             window = new Window (this);
-            window.delete_event.connect(() => {
-               return window.hide_on_delete();
+            window.delete_event.connect (() => {
+               return window.hide_on_delete ();
             });
         }
     }
@@ -52,8 +52,8 @@ public class Application : Gtk.Application {
 
         Gtk.Window.set_default_icon_name (Config.APP_ID);
 
-        add_main_option_entries (option_entries);
-        add_action_entries (action_entries, this);
+        add_main_option_entries (OPTION_ENTRIES);
+        add_action_entries (ACTION_ENTRIES, this);
 
         search_provider = new SearchProvider ();
         search_provider.activate.connect ((timestamp) => {
@@ -110,7 +110,7 @@ public class Application : Gtk.Application {
     private void update_theme (Gtk.Settings settings) {
         string theme_name;
 
-        settings.get("gtk-theme-name", out theme_name);
+        settings.get ("gtk-theme-name", out theme_name);
         Utils.load_theme_css (theme_name);
     }
 
@@ -119,13 +119,13 @@ public class Application : Gtk.Application {
 
         Utils.load_main_css ();
 
-        set_resource_base_path("/org/gnome/clocks/");
+        set_resource_base_path ("/org/gnome/clocks/");
 
         var theme = Gtk.IconTheme.get_default ();
-        theme.add_resource_path("/org/gnome/clocks/icons");
+        theme.add_resource_path ("/org/gnome/clocks/icons");
 
         var settings = Gtk.Settings.get_default ();
-        settings.notify["gtk-theme-name"].connect(() => {
+        settings.notify["gtk-theme-name"].connect (() => {
             update_theme (settings);
         });
         update_theme (settings);
@@ -139,7 +139,7 @@ public class Application : Gtk.Application {
     }
 
     protected override int handle_local_options (GLib.VariantDict options) {
-        if (options.contains("version")) {
+        if (options.contains ("version")) {
             print ("%s %s\n", Environment.get_application_name (), Config.VERSION);
             return 0;
         }
@@ -157,7 +157,7 @@ public class Application : Gtk.Application {
         window.present ();
 
         var world = GWeather.Location.get_world ();
-        var location = world.deserialize (parameter.get_child_value(0));
+        var location = world.deserialize (parameter.get_child_value (0));
         if (location != null) {
             window.add_world_location (location);
         }
diff --git a/src/geocoding.vala b/src/geocoding.vala
index 1c0e2c2..9277fbf 100644
--- a/src/geocoding.vala
+++ b/src/geocoding.vala
@@ -80,7 +80,7 @@ public class Info : Object {
     }
 
     private double get_distance (double latitude1, double longitude1, double latitude2, double longitude2) {
-        const double earth_radius = 6372.795d;
+        const double EARTH_RADIUS = 6372.795d;
 
         double lat1 = deg_to_rad (latitude1);
         double lat2 = deg_to_rad (latitude2);
@@ -88,7 +88,7 @@ public class Info : Object {
         double lon2 = deg_to_rad (longitude2);
 
         return Math.acos (Math.cos (lat1) * Math.cos (lat2) * Math.cos (lon1 - lon2) +
-                          Math.sin (lat1) * Math.sin (lat2)) * earth_radius;
+                          Math.sin (lat1) * Math.sin (lat2)) * EARTH_RADIUS;
     }
 
     private async void search_locations (GWeather.Location location) {
@@ -128,8 +128,8 @@ public class Info : Object {
             string? country_code = location.get_country ();
             string? found_country_code = found_location.get_country ();
             if (country_code != null && country_code == found_country_code) {
-                GWeather.Timezone? timezone = location.get_timezone();
-                GWeather.Timezone? found_timezone = found_location.get_timezone();
+                GWeather.Timezone? timezone = location.get_timezone ();
+                GWeather.Timezone? found_timezone = found_location.get_timezone ();
 
                 if (timezone != null && found_timezone != null) {
                     string? tzid = timezone.get_tzid ();
diff --git a/src/headerbar.vala b/src/headerbar.vala
index 124871f..a114e23 100644
--- a/src/headerbar.vala
+++ b/src/headerbar.vala
@@ -70,7 +70,7 @@ public class Clocks.HeaderBar : Hdy.HeaderBar {
                     centering_policy = STRICT;
                     break;
             }
-            
+
             show_close_button = _mode != SELECTION;
         }
     }
@@ -100,7 +100,7 @@ public class Clocks.HeaderBar : Hdy.HeaderBar {
         get {
             return _can_select;
         }
-        
+
         set {
             _can_select = value;
             if (_can_select) {
diff --git a/src/search-provider.vala b/src/search-provider.vala
index 4593743..7fe6927 100644
--- a/src/search-provider.vala
+++ b/src/search-provider.vala
@@ -51,21 +51,21 @@ public class SearchProvider : Object {
     }
 
     private string serialize_location (GWeather.Location location) {
-        return location.serialize().print(false);
+        return location.serialize ().print (false);
     }
 
     private GWeather.Location? deserialize_location (string str) {
         Variant? variant;
 
         try {
-            variant = Variant.parse(new VariantType ("(uv)"), str, null, null);
+            variant = Variant.parse (new VariantType ("(uv)"), str, null, null);
         } catch (GLib.VariantParseError e) {
             warning ("Malformed variant: %s", e.message);
             return null;
         }
 
         var world = GWeather.Location.get_world ();
-        return world.deserialize(variant);
+        return world.deserialize (variant);
     }
 
     private async void search_locations_recurse (GWeather.Location location, string[] normalized_terms,
@@ -76,7 +76,7 @@ public class SearchProvider : Object {
                 var level = locations[i].get_level ();
                 if (level == GWeather.LocationLevel.CITY ||
                     level == GWeather.LocationLevel.NAMED_TIMEZONE) {
-                    if (location_matches(locations[i], normalized_terms)) {
+                    if (location_matches (locations[i], normalized_terms)) {
                         matches.add (locations[i]);
                     }
                 }
@@ -96,7 +96,7 @@ public class SearchProvider : Object {
         matches.foreach ((location) => {
             // FIXME: Avoid cities without children locations
             if (location.get_level () == GWeather.LocationLevel.CITY &&
-                location.get_children().length == 0) {
+                location.get_children ().length == 0) {
                 return;
             }
             // HACK: the search provider interface does not currently allow variants as result IDs
@@ -143,12 +143,12 @@ public class SearchProvider : Object {
             var meta = new HashTable<string, Variant> (str_hash, str_equal);
             var item = new World.Item (location);
             string time_label = item.time_label;
-            string day =  item.day_label;
+            string day = item.day_label;
             if (day != null) {
                 time_label += " " + day;
             }
             count++;
-            meta.insert ("id", count.to_string());
+            meta.insert ("id", count.to_string ());
             meta.insert ("name", time_label);
             meta.insert ("description", item.name);
 
diff --git a/src/stopwatch.vala b/src/stopwatch.vala
index 301b3f9..93eef03 100644
--- a/src/stopwatch.vala
+++ b/src/stopwatch.vala
@@ -40,7 +40,7 @@ public class Frame : AnalogFrame {
         context.add_class ("progress");
 
         cr.set_line_width (LINE_WIDTH);
-        cr.set_line_cap  (Cairo.LineCap.ROUND);
+        cr.set_line_cap (Cairo.LineCap.ROUND);
 
         var color = context.get_color (context.get_state ());
         var progress = ((double) seconds + millisecs) / 60;
@@ -48,7 +48,7 @@ public class Frame : AnalogFrame {
             cr.arc (center_x,
                     center_y,
                     radius - LINE_WIDTH / 2,
-                    1.5  * Math.PI,
+                    1.5 * Math.PI,
                     (1.5 + progress * 2 ) * Math.PI);
             Gdk.cairo_set_source_rgba (cr, color);
             cr.stroke ();
@@ -241,7 +241,7 @@ public class Face : Gtk.Box, Clocks.Clock {
         // 0.108000 and the next lap is 1.202000, we would see on screen 0.10
         // and 1.20, so we would expect a split time of 1.10, but we would
         // instead get 1.094000 and thus display 1.09
-        last_lap_time = Math.floor(e * 100) / 100;
+        last_lap_time = Math.floor (e * 100) / 100;
 
         int h;
         int m;
diff --git a/src/timer.vala b/src/timer.vala
index 3e437e1..566eca6 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -53,10 +53,10 @@ public class CountdownFrame : AnalogFrame {
 
         var color = context.get_color (context.get_state ());
 
-        cr.arc (center_x, center_y, radius - LINE_WIDTH / 2, 1.5  * Math.PI, (1.5 + (1 - progress) * 2 ) * 
Math.PI);
+        cr.arc (center_x, center_y, radius - LINE_WIDTH / 2, 1.5 * Math.PI, (1.5 + (1 - progress) * 2 ) * 
Math.PI);
         Gdk.cairo_set_source_rgba (cr, color);
         cr.set_line_width (LINE_WIDTH);
-        cr.set_line_cap  (Cairo.LineCap.ROUND);
+        cr.set_line_cap (Cairo.LineCap.ROUND);
         cr.stroke ();
 
         context.restore ();
@@ -127,9 +127,9 @@ public class Face : Gtk.Stack, Clocks.Clock {
         timer = new GLib.Timer ();
 
         timeout_id = 0;
-        destroy.connect(() => {
+        destroy.connect (() => {
             if (timeout_id != 0) {
-                GLib.Source.remove(timeout_id);
+                GLib.Source.remove (timeout_id);
                 timeout_id = 0;
             }
         });
@@ -153,7 +153,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
 
     [GtkCallback]
     private bool show_leading_zeros (Gtk.SpinButton spin_button) {
-        spin_button.set_text ("%02i".printf(spin_button.get_value_as_int ()));
+        spin_button.set_text ("%02i".printf (spin_button.get_value_as_int ()));
         return true;
     }
 
@@ -222,7 +222,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
         case State.PAUSED:
             start ();
             left_button.set_label (_("Pause"));
-            left_button.get_style_context ().remove_class("suggested-action");
+            left_button.get_style_context ().remove_class ("suggested-action");
             break;
         default:
             assert_not_reached ();
@@ -242,7 +242,7 @@ public class Face : Gtk.Stack, Clocks.Clock {
         h_spinbutton.value = (int) span / 3600;
         m_spinbutton.value = (int) span % 3600 / 60;
         s_spinbutton.value = span % 60;
-        left_button.get_style_context ().remove_class("clocks-go");
+        left_button.get_style_context ().remove_class ("clocks-go");
         countdown_frame.get_style_context ().remove_class ("clocks-paused");
         start_button.set_sensitive (span > 0);
         countdown_frame.reset ();
@@ -267,8 +267,8 @@ public class Face : Gtk.Stack, Clocks.Clock {
 
         state = State.RUNNING;
         timer.start ();
-        timeout_id = GLib.Timeout.add(40, () => {
-           if (state != State.RUNNING) {
+        timeout_id = GLib.Timeout.add (40, () => {
+            if (state != State.RUNNING) {
                 timeout_id = 0;
                 return false;
             }
diff --git a/src/utils.vala b/src/utils.vala
index 84af1b8..cd35ea8 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -24,7 +24,7 @@ namespace Utils {
 private void load_css (string css, bool required) {
     var provider = new Gtk.CssProvider ();
     try {
-        var file = File.new_for_uri("resource:///org/gnome/clocks/css/" + css + ".css");
+        var file = File.new_for_uri ("resource:///org/gnome/clocks/css/" + css + ".css");
         provider.load_from_file (file);
     } catch (Error e) {
         if (required) {
@@ -34,7 +34,7 @@ private void load_css (string css, bool required) {
         return;
     }
 
-    Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default(),
+    Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (),
                                               provider,
                                               Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
 }
@@ -155,15 +155,15 @@ public class Weekdays {
         SUN
     }
 
-    private const bool[] weekdays = {
+    private const bool[] WEEKDAYS = {
         true, true, true, true, true, false, false
     };
 
-    private const bool[] weekends = {
+    private const bool[] WEEKENDS = {
         false, false, false, false, false, true, true
     };
 
-    private const string[] plurals = {
+    private const string[] PLURALS = {
         N_("Mondays"),
         N_("Tuesdays"),
         N_("Wednesdays"),
@@ -182,7 +182,7 @@ public class Weekdays {
 
     public static string plural (Day d) {
         assert (d >= 0 && d < 7);
-        return _(plurals[d]);
+        return _(PLURALS[d]);
     }
 
     public static string abbreviation (Day d) {
@@ -204,11 +204,11 @@ public class Weekdays {
         return abbreviations[d];
     }
 
-    private bool[] days= {
+    private bool[] days = {
         false, false, false, false, false, false, false
     };
 
-    public Weekdays() {
+    public Weekdays () {
     }
 
     public bool empty {
@@ -251,9 +251,9 @@ public class Weekdays {
             r = plural ((Day) first);
         } else if (n == 7) {
             r = _("Every Day");
-        } else if (days_equal (weekdays)) {
+        } else if (days_equal (WEEKDAYS)) {
             r = _("Weekdays");
-        } else if (days_equal (weekends)) {
+        } else if (days_equal (WEEKENDS)) {
             r = _("Weekends");
         } else {
             string[] abbrs = {};
@@ -280,7 +280,7 @@ public class Weekdays {
             }
             i++;
         }
-        return builder.end ();;
+        return builder.end ();
     }
 
     public static Weekdays deserialize (GLib.Variant days_variant) {
@@ -305,15 +305,15 @@ public class Bell : Object {
 
     public Bell (string soundid) {
         try {
-            gsound = new GSound.Context();
+            gsound = new GSound.Context ();
         } catch (GLib.Error e) {
             warning ("Sound could not be initialized, error: %s", e.message);
         }
 
-        var settings = new GLib.Settings("org.gnome.desktop.sound");
+        var settings = new GLib.Settings ("org.gnome.desktop.sound");
         soundtheme = settings.get_string ("theme-name");
         sound = soundid;
-        cancellable = new GLib.Cancellable();
+        cancellable = new GLib.Cancellable ();
     }
 
     private async void ring_real (bool repeat) {
@@ -321,7 +321,7 @@ public class Bell : Object {
             return;
         }
 
-        if (cancellable.is_cancelled()) {
+        if (cancellable.is_cancelled ()) {
             cancellable.reset ();
         }
 
@@ -348,7 +348,7 @@ public class Bell : Object {
     }
 
     public void stop () {
-        cancellable.cancel();
+        cancellable.cancel ();
     }
 }
 
diff --git a/src/window.vala b/src/window.vala
index a9df644..8d510e3 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -20,7 +20,7 @@ namespace Clocks {
 
 [GtkTemplate (ui = "/org/gnome/clocks/ui/window.ui")]
 public class Window : Gtk.ApplicationWindow {
-    private const GLib.ActionEntry[] action_entries = {
+    private const GLib.ActionEntry[] ACTION_ENTRIES = {
         // primary menu
         { "show-primary-menu", on_show_primary_menu_activate, null, "false", null },
         { "new", on_new_activate },
@@ -64,12 +64,12 @@ public class Window : Gtk.ApplicationWindow {
     public Window (Application app) {
         Object (application: app);
 
-        add_action_entries (action_entries, this);
+        add_action_entries (ACTION_ENTRIES, this);
 
         settings = new Settings ("org.gnome.clocks.state.window");
         settings.delay ();
 
-        destroy.connect(() => {
+        destroy.connect (() => {
             settings.apply ();
         });
 
@@ -117,7 +117,7 @@ public class Window : Gtk.ApplicationWindow {
                                      Gdk.Key.Page_Up,
                                      Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK,
                                      "change-page", 1,
-                                     typeof(int), 0);
+                                     typeof (int), 0);
         Gtk.BindingEntry.add_signal (binding_set,
                                      Gdk.Key.Page_Down,
                                      Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK,
@@ -132,7 +132,7 @@ public class Window : Gtk.ApplicationWindow {
         show_all ();
     }
 
-    [Signal(action = true)]
+    [Signal (action = true)]
     public virtual signal void change_page (int offset) {
         var dir = false;
 
@@ -264,12 +264,12 @@ public class Window : Gtk.ApplicationWindow {
     }
 
     private void on_about_activate () {
-        const string copyright = "Copyright \xc2\xa9 2011 Collabora Ltd.\n" +
+        const string COPYRIGHT = "Copyright \xc2\xa9 2011 Collabora Ltd.\n" +
                                  "Copyright \xc2\xa9 2012-2013 Collabora Ltd., Seif Lotfy, Emily Gonyer\n" +
-                                 "Eslam Mostafa, Paolo Borelli, Volker Sobek\n" + 
+                                 "Eslam Mostafa, Paolo Borelli, Volker Sobek\n" +
                                  "Copyright \xc2\xa9 2019 Bilal Elmoussaoui & Zander Brown et al";
 
-        const string authors[] = {
+        const string AUTHORS[] = {
             "Alex Anthony",
             "Paolo Borelli",
             "Allan Day",
@@ -294,8 +294,8 @@ public class Window : Gtk.ApplicationWindow {
                                "logo-icon-name", Config.APP_ID,
                                "version", Config.VERSION,
                                "comments", _("Utilities to help you with the time."),
-                               "copyright", copyright,
-                               "authors", authors,
+                               "copyright", COPYRIGHT,
+                               "authors", AUTHORS,
                                "license-type", Gtk.License.GPL_2_0,
                                "wrap-license", false,
                                "translator-credits", _("translator-credits"),
@@ -311,7 +311,7 @@ public class Window : Gtk.ApplicationWindow {
             return;
         }
 
-        help_overlay.view_name = Type.from_instance (panel).name();
+        help_overlay.view_name = Type.from_instance (panel).name ();
 
         if (inited) {
             settings.set_enum ("panel-id", panel.panel_id);
@@ -372,7 +372,7 @@ public class Window : Gtk.ApplicationWindow {
                                               header_bar,
                                               "new-label",
                                               SYNC_CREATE);
-                                    
+
         stack.visible_child.grab_focus ();
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]