From 8d10da3cc64f11d0f9e451ae32979edae391eb07 Mon Sep 17 00:00:00 2001 From: Jens True Date: Sat, 3 Jul 2021 23:12:20 +0200 Subject: [PATCH] Code formatting. Remove traces of static analysis in drone build --- .drone.yml | 12 +----------- Tidstagning/Entry.cs | 2 +- Tidstagning/Form1.cs | 27 +++++++++++++++------------ Tidstagning/Procedure.cs | 15 ++++++++------- Tidstagning/Relay.cs | 20 +++++++++++--------- Tidstagning/ResultList.cs | 9 +++++---- Tidstagning/Settings.cs | 25 +++++++++++++++---------- 7 files changed, 56 insertions(+), 54 deletions(-) diff --git a/.drone.yml b/.drone.yml index 84d19bd..a2db58e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,14 +4,4 @@ steps: - name: build image: mono commands: - - msbuild Tidstagning.sln -- name: sca - image: azimarev/mono-sonarqube-scanner - failure: ignore - commands: - - mono /opt/sonar-scanner-msbuild/SonarScanner.MSBuild.exe begin /k:"tidstagning" /d:sonar.host.url="https://sonarqube.jcktrue.dk" /d:sonar.login="$TOKEN" - - msbuild Tidstagning.sln - - mono /opt/sonar-scanner-msbuild/SonarScanner.MSBuild.exe sonarscanner end /d:sonar.login="$TOKEN" - environment: - TOKEN: - from_secret: SONARQUBE_TOKEN \ No newline at end of file + - msbuild Tidstagning.sln \ No newline at end of file diff --git a/Tidstagning/Entry.cs b/Tidstagning/Entry.cs index b3985c7..b4615be 100644 --- a/Tidstagning/Entry.cs +++ b/Tidstagning/Entry.cs @@ -9,7 +9,7 @@ namespace Tidstagning public string SailNumber { get; set; } public DateTime Completed_Time { get; set; } - + public Entry(string name, string number) { this.Name = name; diff --git a/Tidstagning/Form1.cs b/Tidstagning/Form1.cs index ab16b9a..45d0191 100644 --- a/Tidstagning/Form1.cs +++ b/Tidstagning/Form1.cs @@ -7,7 +7,8 @@ namespace Tidstagning public partial class Form1 : Form { delegate void SetTextCallback(string text); - BindingList entries = new BindingList { + BindingList entries = new BindingList + { }; ResultList liste; @@ -22,13 +23,14 @@ namespace Tidstagning while ((deltager = deltager_handle.ReadLine()) != null) { string[] dele = deltager.Split(','); - entries.Add(new Entry(dele[0],dele[1])); + entries.Add(new Entry(dele[0], dele[1])); } deltager_handle.Dispose(); comboSoundTime.SelectedIndex = 0; - foreach (string port in Relay.GetPorts()) { + foreach (string port in Relay.GetPorts()) + { comboComport.Items.Add(port); } @@ -57,7 +59,7 @@ namespace Tidstagning } } - + private void Form1_Load(object sender, EventArgs e) { grid.DataSource = entries; @@ -72,7 +74,7 @@ namespace Tidstagning } else { - this.txtDebug.AppendText( text ); + this.txtDebug.AppendText(text); } } @@ -85,15 +87,16 @@ namespace Tidstagning { entries[e.RowIndex].DNF(); liste.WriteDNF(entries[e.RowIndex]); - + grid.ClearSelection(); grid.CurrentCell = null; entries.RemoveAt(e.RowIndex); } - if (e.RowIndex >= 0 && e.ColumnIndex == grid.Columns["Complete"].Index) { + if (e.RowIndex >= 0 && e.ColumnIndex == grid.Columns["Complete"].Index) + { entries[e.RowIndex].Complete(); liste.WriteComplete(entries[e.RowIndex]); - + grid.ClearSelection(); grid.CurrentCell = null; entries.RemoveAt(e.RowIndex); @@ -187,7 +190,7 @@ namespace Tidstagning { startprocedure.ReadFile(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + "Startprocedure.txt"); } - + Properties.Settings.Default.AutoStartProcedure = checkStartProcedure.Checked; Properties.Settings.Default.Save(); @@ -195,7 +198,7 @@ namespace Tidstagning private void grid_CellMouseEnter(object sender, DataGridViewCellEventArgs e) { - if (e.RowIndex > -1 ) + if (e.RowIndex > -1) { try { @@ -213,13 +216,13 @@ namespace Tidstagning private void grid_CellMouseLeave(object sender, DataGridViewCellEventArgs e) { - if (e.RowIndex > -1 ) + if (e.RowIndex > -1) { try { grid.Rows[e.RowIndex].Selected = false; grid.Rows[e.RowIndex].Height = 30; - + } catch { } diff --git a/Tidstagning/Procedure.cs b/Tidstagning/Procedure.cs index 3b6d930..25a6cd5 100644 --- a/Tidstagning/Procedure.cs +++ b/Tidstagning/Procedure.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -using System.Threading; using System.Diagnostics; +using System.Threading; namespace Tidstagning { @@ -11,7 +11,7 @@ namespace Tidstagning ResultList log; List signaler; int signalLength = 500; - + Timer timer; Int16 idx = 0; @@ -31,7 +31,8 @@ namespace Tidstagning procedure_handle.Dispose(); } - public void addEntry(string input) { + public void addEntry(string input) + { string input_filtered = input.Trim(); if (input_filtered.Length > 0) { @@ -41,7 +42,7 @@ namespace Tidstagning } catch { - Debug.WriteLine("Failed to parse: "+ input); + Debug.WriteLine("Failed to parse: " + input); } signaler.Sort(); } @@ -76,7 +77,7 @@ namespace Tidstagning { signaler = new List(); idx = 0; - if(timer != null) + if (timer != null) timer.Dispose(); } @@ -107,7 +108,7 @@ namespace Tidstagning if (timeToGo < TimeSpan.Zero) { - if(!next()) + if (!next()) { return; } @@ -118,7 +119,7 @@ namespace Tidstagning timer = new System.Threading.Timer(x => { this.Alarm(); - }, null, timeToGo, new System.TimeSpan (0)); + }, null, timeToGo, new System.TimeSpan(0)); } private void Alarm() diff --git a/Tidstagning/Relay.cs b/Tidstagning/Relay.cs index 5403226..001c4ea 100644 --- a/Tidstagning/Relay.cs +++ b/Tidstagning/Relay.cs @@ -1,8 +1,8 @@ -using System.IO.Ports; -using System; +using System; using System.Collections.Generic; -using System.Threading; using System.Diagnostics; +using System.IO.Ports; +using System.Threading; namespace Tidstagning { class Relay @@ -61,15 +61,17 @@ namespace Tidstagning } } - private void Set(int output, byte state) { - byte[] command = {0xff, 0x01, state}; + private void Set(int output, byte state) + { + byte[] command = { 0xff, 0x01, state }; if (com.IsOpen) { Debug.WriteLine("COM: " + com.PortName + " Write: 0x" + Convert.ToString(command[2], 16)); com.Write(command, 0, 3); } } - public void Close() { + public void Close() + { if (com.IsOpen) { Off(); //Make sure the horn is off before closing the com port... @@ -79,15 +81,15 @@ namespace Tidstagning public static string[] GetPorts() { - string[] ports; - + string[] ports; + if (SerialPort.GetPortNames().Length != 0) { ports = SerialPort.GetPortNames(); } else { - ports = new string[]{ "N/A" }; + ports = new string[] { "N/A" }; } return ports; } diff --git a/Tidstagning/ResultList.cs b/Tidstagning/ResultList.cs index 57d8d52..84e7294 100644 --- a/Tidstagning/ResultList.cs +++ b/Tidstagning/ResultList.cs @@ -12,7 +12,7 @@ namespace Tidstagning public ResultList(string filename, Tidstagning.Form1 log_object) { filename = MakeSafeFilename(filename, '_'); - filehandle = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename +"_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".txt"); + filehandle = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".txt"); filehandle2 = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".csv"); parentForm = log_object; } @@ -26,7 +26,8 @@ namespace Tidstagning return filename; } - public void WriteHeader(string header) { + public void WriteHeader(string header) + { this.racenumber = header; Write("----------------------------"); Write(header); @@ -46,13 +47,13 @@ namespace Tidstagning public void WriteComplete(Entry Boat) { Write("Fuldført! - " + Boat.Name + " - " + Boat.Completed_Time.ToString()); - WriteCSV(this.racenumber + "," +Boat.SailNumber + "," + Boat.Completed_Time.ToString("HH:mm:ss") + ", ,"); + WriteCSV(this.racenumber + "," + Boat.SailNumber + "," + Boat.Completed_Time.ToString("HH:mm:ss") + ", ,"); } public void WriteDNF(Entry Boat) { Write("Udgået! - " + Boat.Name + " - " + Boat.Completed_Time.ToString()); - WriteCSV(this.racenumber + "," +Boat.SailNumber + "," + "00:00:00,DNC,"); + WriteCSV(this.racenumber + "," + Boat.SailNumber + "," + "00:00:00,DNC,"); } public void Write(string textstring) diff --git a/Tidstagning/Settings.cs b/Tidstagning/Settings.cs index c33543e..d630a32 100644 --- a/Tidstagning/Settings.cs +++ b/Tidstagning/Settings.cs @@ -1,14 +1,17 @@ -namespace Tidstagning.Properties { - - +namespace Tidstagning.Properties +{ + + // This class allows you to handle specific events on the settings class: // The SettingChanging event is raised before a setting's value is changed. // The PropertyChanged event is raised after a setting's value is changed. // The SettingsLoaded event is raised after the setting values are loaded. // The SettingsSaving event is raised before the setting values are saved. - internal sealed partial class Settings { - - public Settings() { + internal sealed partial class Settings + { + + public Settings() + { // // To add event handlers for saving and changing settings, uncomment the lines below: // // this.SettingChanging += this.SettingChangingEventHandler; @@ -16,12 +19,14 @@ // this.SettingsSaving += this.SettingsSavingEventHandler; // } - - private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { + + private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) + { // Add code to handle the SettingChangingEvent event here. } - - private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { + + private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) + { // Add code to handle the SettingsSaving event here. } }