diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..58ecbdb --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,25 @@ +# This is a basic workflow to help you get started with Actions + +name: Linting + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: elementary/actions/vala-lint@master + with: + dir: src/ + conf: .vala-lint.conf + fail: true diff --git a/.uncrustify.cfg b/.uncrustify.cfg index d45c627..6d787c9 100644 --- a/.uncrustify.cfg +++ b/.uncrustify.cfg @@ -355,7 +355,7 @@ sp_before_byref_func = force # ignore/add/remove/force sp_after_type = force # ignore/add/remove/force # Add or remove space before the paren in the D constructs 'template Foo(' and 'class Foo('. -sp_before_template_paren = ignore # ignore/add/remove/force +sp_before_template_paren = force # ignore/add/remove/force # Add or remove space in 'template <' vs 'template<'. # If set to ignore, sp_before_angle is used. @@ -371,7 +371,7 @@ sp_inside_angle = remove # ignore/add/remove/force sp_after_angle = remove # ignore/add/remove/force # Add or remove space between '<>' and '(' as found in 'new List();' -sp_angle_paren = remove # ignore/add/remove/force +sp_angle_paren = force # ignore/add/remove/force # Add or remove space between '<>' and a word as in 'List m;' sp_angle_word = force # ignore/add/remove/force diff --git a/.vala-lint.conf b/.vala-lint.conf new file mode 100644 index 0000000..1446348 --- /dev/null +++ b/.vala-lint.conf @@ -0,0 +1,27 @@ +[Checks] +block-opening-brace-space-before=error +double-semicolon=error +double-spaces=error +ellipsis=off +line-length=warn +naming-convention=error +no-space=error +note=warn +space-before-paren=error +use-of-tabs=error +trailing-newlines=error +trailing-whitespace=error +unnecessary-string-template=error + +[Disabler] +disable-by-inline-comments=true + +[line-length] +max-line-length=120 +ignore-comments=true + +[naming-convention] +exceptions=UUID, + +[note] +keywords=TODO,FIXME, diff --git a/src/ccDaemon/ccDaemon.vala b/src/ccDaemon/ccDaemon.vala index 989a660..c79ff8b 100644 --- a/src/ccDaemon/ccDaemon.vala +++ b/src/ccDaemon/ccDaemon.vala @@ -1,17 +1,17 @@ namespace SwayNotificationCenter { [DBus (name = "org.erikreider.swaync.cc")] public class CcDaemon : Object { - public ControlCenter controlCenter; - public NotiDaemon notiDaemon; + public ControlCenter control_center; + public NotiDaemon noti_daemon; - public CcDaemon (NotiDaemon notiDaemon) { - this.notiDaemon = notiDaemon; - this.controlCenter = new ControlCenter (this); + public CcDaemon (NotiDaemon noti_daemon) { + this.noti_daemon = noti_daemon; + this.control_center = new ControlCenter (this); - notiDaemon.on_dnd_toggle.connect ((dnd) => { - this.controlCenter.set_switch_dnd_state (dnd); + noti_daemon.on_dnd_toggle.connect ((dnd) => { + this.control_center.set_switch_dnd_state (dnd); try { - subscribe (controlCenter.notification_count (), + subscribe (control_center.notification_count (), dnd, get_visibility ()); } catch (Error e) { @@ -38,7 +38,7 @@ namespace SwayNotificationCenter { /** Reloads the CSS file */ public bool reload_css () throws Error { bool result = Functions.load_css (style_path); - if (result) controlCenter.reload_notifications_style (); + if (result) control_center.reload_notifications_style (); return result; } @@ -67,32 +67,32 @@ namespace SwayNotificationCenter { /** Gets the controlcenter visibility */ public bool get_visibility () throws DBusError, IOError { - return controlCenter.get_visibility (); + return control_center.get_visibility (); } /** Closes latest popup notification */ public void hide_latest_notifications (bool close) throws DBusError, IOError { - notiDaemon.hide_latest_notification (close); + noti_daemon.hide_latest_notification (close); } /** Closes all popup and controlcenter notifications */ public void close_all_notifications () throws DBusError, IOError { - notiDaemon.close_all_notifications (); + noti_daemon.close_all_notifications (); } /** Gets the current controlcenter notification count */ public uint notification_count () throws DBusError, IOError { - return controlCenter.notification_count (); + return control_center.notification_count (); } /** Toggles the visibility of the controlcenter */ public void toggle_visibility () throws DBusError, IOError { - if (controlCenter.toggle_visibility ()) { - notiDaemon.set_noti_window_visibility (false); + if (control_center.toggle_visibility ()) { + noti_daemon.set_noti_window_visibility (false); } try { - subscribe (controlCenter.notification_count (), + subscribe (control_center.notification_count (), get_dnd (), get_visibility ()); } catch (Error e) { @@ -102,10 +102,10 @@ namespace SwayNotificationCenter { /** Sets the visibility of the controlcenter */ public void set_visibility (bool visibility) throws DBusError, IOError { - controlCenter.set_visibility (visibility); - if (visibility) notiDaemon.set_noti_window_visibility (false); + control_center.set_visibility (visibility); + if (visibility) noti_daemon.set_noti_window_visibility (false); try { - subscribe (controlCenter.notification_count (), + subscribe (control_center.notification_count (), get_dnd (), visibility); } catch (Error e) { @@ -115,28 +115,28 @@ namespace SwayNotificationCenter { /** Toggles the current Do Not Disturb state */ public bool toggle_dnd () throws DBusError, IOError { - return notiDaemon.toggle_dnd (); + return noti_daemon.toggle_dnd (); } /** Sets the current Do Not Disturb state */ public void set_dnd (bool state) throws DBusError, IOError { - notiDaemon.set_dnd (state); + noti_daemon.set_dnd (state); } /** Gets the current Do Not Disturb state */ public bool get_dnd () throws DBusError, IOError { - return notiDaemon.get_dnd (); + return noti_daemon.get_dnd (); } /** Adds a new notification */ public void add_notification (NotifyParams param) throws DBusError, IOError { - controlCenter.add_notification (param, notiDaemon); + control_center.add_notification (param, noti_daemon); } /** Closes a specific notification with the `id` */ public void close_notification (uint32 id) throws DBusError, IOError { - controlCenter.close_notification (id); + control_center.close_notification (id); } } } diff --git a/src/client.vala b/src/client.vala index 05f41e4..f2aa0e4 100644 --- a/src/client.vala +++ b/src/client.vala @@ -27,26 +27,27 @@ interface CcDaemon : GLib.Object { private CcDaemon cc_daemon = null; private void print_help (string[] args) { - print (@"Usage:\n"); - print (@"\t $(args[0])