Skip to content

Commit

Permalink
Improving Code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Fawcett committed Jan 18, 2023
1 parent 3c4cb8f commit 74743a2
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 81 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,18 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Code Coverage Report
uses: codecov/codecov-action@v3
if: always()
with:
token: ${{ secrets.CODECOV }}
files: SimListenerTest/coverage.opencover.xml


- name: Upload Results for Publishing
uses: actions/upload-artifact@v3
if: always()
with:
name: Results
path: SimListenerTest/TestResults/*.trx
path: SimListenerTest/TestResults/*.trx , SimListenerTest/coverage.opencover.xml

results:
name: Results
runs-on: ubuntu-latest
if: always()
needs: [ test ]
steps:
- name: Download built project
Expand All @@ -67,7 +62,14 @@ jobs:
uses: EnricoMi/publish-unit-test-result-action@v2
with:
trx_files: "*.trx"


- name: Code Coverage Report
uses: codecov/codecov-action@v3
if: always()
with:
token: ${{ secrets.CODECOV }}
files: coverage.opencover.xml

package:
name: Package
if: github.ref == 'refs/heads/main'
Expand Down
22 changes: 0 additions & 22 deletions SimListener/Connect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,11 @@

namespace SimListener
{
internal enum DEFINITION
{
Dummy = 0
};
internal enum REQUEST
{
Dummy = 0,
Struct1
};
internal enum EVENT
{
RECUR_1SEC,
}
internal enum REQUESTS
{
SIMULATION,
AIRCRAFT_LOADED,
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
internal struct ResultStructure
{
// this is how you declare a fixed size string
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string sValue;

// other definitions can be added to this struct
// ...
};

public class Connect
Expand Down
26 changes: 26 additions & 0 deletions SimListener/Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace SimListener
{
public enum ErrorCodes
{
OK,
INVALID_DATA_REQUEST,
}
internal enum DEFINITION
{
Dummy = 0
};
internal enum REQUEST
{
Dummy = 0,
Struct1
};
internal enum EVENT
{
RECUR_1SEC,
}
internal enum REQUESTS
{
SIMULATION,
AIRCRAFT_LOADED,
}
}
8 changes: 0 additions & 8 deletions SimListener/ErrorCodes.cs

This file was deleted.

42 changes: 1 addition & 41 deletions SimListener/Track.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace SimListener
{
public class Track : IEquatable<Track>
public class Track
{
private double latitude = 0;
private double longitude = 0;
Expand Down Expand Up @@ -32,46 +32,6 @@ public string Heading
get => heading.ToString();
set => _ = double.TryParse(value, out heading);
}

public override bool Equals(object? obj)
{
return obj is not null && Equals(obj as Track);
}

public bool Equals(Track? other)
{
return other is not null
&& latitude == other.latitude &&
longitude == other.longitude &&
altitude == other.altitude &&
airspeed == other.airspeed &&
heading == other.heading;
}

public override int GetHashCode()
{
return HashCode.Combine(latitude, longitude, altitude, airspeed, heading);
}

public override string ToString()
{
return "Lat = " + latitude +
" Long = " + longitude +
" Alt = " + altitude +
" Speed = " + airspeed +
" Head = " + heading;
}

public static bool operator ==(Track left, Track right)
{
return EqualityComparer<Track>.Default.Equals(left, right);
}

public static bool operator !=(Track left, Track right)
{
return !(left == right);
}

internal bool Zero()
{
return latitude == 0 && longitude == 0 && altitude == 0 && airspeed == 0 && heading == 0;
Expand Down

0 comments on commit 74743a2

Please sign in to comment.