Skip to content

Commit

Permalink
Quality code (#3)
Browse files Browse the repository at this point in the history
* Update CHANGELOG.md
* Update README.md
* Add a 'default' clause to this 'switch' statement.
* Remove this redundant 'base()' call.
* Define the locale to be used in this string operation.
* Overrides 'GetHashCode' and should therefore also override 'Equals'.
  • Loading branch information
rfavreau authored Sep 4, 2022
1 parent 8d118cd commit 058cd01
Show file tree
Hide file tree
Showing 24 changed files with 37 additions and 20 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

6 changes: 3 additions & 3 deletions OFX-Tool.Library/Core/ExportToXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ private string ReturnFinalTag(string content)
{
var returnFinal = string.Empty;

if ((content.IndexOf("<") != -1) && (content.IndexOf(">") != -1))
if ((content.IndexOf("<", StringComparison.InvariantCulture) != -1) && (content.IndexOf(">", StringComparison.InvariantCulture) != -1))
{
int position1 = content.IndexOf("<");
int position2 = content.IndexOf(">");
int position1 = content.IndexOf("<", StringComparison.InvariantCulture);
int position2 = content.IndexOf(">", StringComparison.InvariantCulture);
if ((position2 - position1) > 2)
{
returnFinal = content.Substring(position1, (position2 - position1) + 1);
Expand Down
2 changes: 2 additions & 0 deletions OFX-Tool.Library/Core/Extract/ExtractAVAILBAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ internal ExtractAVAILBAL(XmlTextReader xmlReader)
case "DTASOF":
Element.DateAsOf = xmlReader.Value;
break;
default:
throw new InvalidOperationException($"Unexpected value! [{myField}]");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions OFX-Tool.Library/Core/Extract/ExtractBANKACCTFROM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ internal ExtractBANKACCTFROM(XmlTextReader xmlReader)
case "ACCTTYPE":
Element.AccountType = (AccountEnum)Enum.Parse(typeof(AccountEnum), xmlReader.Value);
break;
default:
throw new InvalidOperationException($"Unexpected value! [{myField}]");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions OFX-Tool.Library/Core/Extract/ExtractBANKTRANLIST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ internal ExtractBANKTRANLIST(XmlTextReader xmlReader)
case "DTEND":
Element.EndDate = xmlReader.Value;
break;
default:
throw new InvalidOperationException($"Unexpected value! [{myField}]");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions OFX-Tool.Library/Core/Extract/ExtractLEDGERBAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ internal ExtractLEDGERBAL(XmlTextReader xmlReader)
case "DTASOF":
Element.DateAsOf = xmlReader.Value;
break;
default:
throw new InvalidOperationException($"Unexpected value! [{myField}]");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions OFX-Tool.Library/Core/Extract/ExtractSONRS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ internal ExtractSONRS(XmlTextReader xmlReader)
case "LANGUAGE":
Element.Language = (LanguageEnum)Enum.Parse(typeof(LanguageEnum), xmlReader.Value);
break;
default:
throw new InvalidOperationException($"Unexpected value! [{myField}]");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions OFX-Tool.Library/Core/Extract/ExtractSTATUS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ internal ExtractSTATUS(XmlTextReader xmlReader)
case "SEVERITY":
Element.Severity = (SeverityEnum)Enum.Parse(typeof(SeverityEnum), xmlReader.Value);
break;
default:
throw new InvalidOperationException($"Unexpected value! [{myField}]");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions OFX-Tool.Library/Core/Extract/ExtractSTMTRS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ internal ExtractSTMTRS(XmlTextReader xmlReader)
case "CURDEF":
Element.Currency = (CurrencyEnum)Enum.Parse(typeof(CurrencyEnum), xmlReader.Value);
break;
default:
throw new InvalidOperationException($"Unexpected value! [{myField}]");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions OFX-Tool.Library/Core/Extract/ExtractSTMTTRN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ internal ExtractSTMTTRN(XmlTextReader xmlReader)
case "MEMO":
Element.Memo = xmlReader.Value;
break;
default:
throw new InvalidOperationException($"Unexpected value! [{myField}]");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions OFX-Tool.Library/Core/Extract/ExtractSTMTTRNRS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ internal ExtractSTMTTRNRS(XmlTextReader xmlReader)
case "TRNUID":
Element.TransactionUniqueId = xmlReader.Value;
break;
default:
throw new InvalidOperationException($"Unexpected value! [{myField}]");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Core/OFXToolException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace RFD.OFXTool.Library.Core
{
public class OFXToolException : Exception
{
public OFXToolException() : base()
public OFXToolException()
{
}

Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/AvailableBalance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AvailableBalance
public string? DateAsOf { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/Bank/BankAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BankAccount
public string? AccountKey { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
// Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/Bank/BankTransactionList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BankTransactionList
public List<StatementTransaction>? StatementTransactions { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/Bank/StatementResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class StatementResponse
public AvailableBalance? AvailableBalance { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/Bank/StatementTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class StatementTransaction
public string? AvailableDate { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
// Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class StatementTransactionResponse : AbstractTransactionResponse
public StatementResponse? StatementResponse { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/BankResponseMessageSetV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class BankResponseMessageSetV1
public List<StatementTransactionResponse>? StatementTransactionResponses { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/LedgerBalance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class LedgerBalance
public string? DateAsOf { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/Signon/SignonResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class SignonResponse
public LanguageEnum? Language { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/SignonResponseMessageSetV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class SignonResponseMessageSetV1
public SignonResponse? SignonResponse { get; set; }

// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
2 changes: 1 addition & 1 deletion OFX-Tool.Library/Entities/Status.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Status


// Determines whether the specified object is equal to the current object.
public override bool Equals(Object? obj)
public override bool Equals(object? obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
C# library for **OFX** file.

[![CICD](https://github.com/rfavreau/OFX-Tool/actions/workflows/CICD.yml/badge.svg)](https://github.com/rfavreau/OFX-Tool/actions/workflows/CICD.yml)
[![Coverage Status](https://coveralls.io/repos/github/rfavreau/OFX-Tool/badge.svg?branch=master)](https://coveralls.io/github/rfavreau/OFX-Tool?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/rfd59/OFX-Tool/badge.svg?branch=quality-code)](https://coveralls.io/github/rfd59/OFX-Tool?branch=quality-code)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/2557b727bfff4ac69b8b4e10a8148a56)](https://www.codacy.com/gh/rfd59/OFX-Tool/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=rfd59/OFX-Tool&amp;utm_campaign=Badge_Grade)
[![Nuget](https://img.shields.io/nuget/v/RFD.OFX-Tool)](https://www.nuget.org/packages/RFD.OFX-Tool)
![GitHub](https://img.shields.io/github/license/rfd59/OFX-Tool)
Expand All @@ -14,11 +14,11 @@ This project provides a .Net 6.0 library to manage the _OFX_ file.
You can extract the data from a _OFX_ file or build an _OFX_ file.

## Links
- [https://schemas.liquid-technologies.com/ofx/2.1.1/](https://schemas.liquid-technologies.com/ofx/2.1.1/)
- [https://schemas.liquid-technologies.com/ofx/2.1.1/](https://schemas.liquid-technologies.com/ofx/2.1.1/)

## Notes
- Inital implementation cloned from [strobelt/ofxparser.netcore](https://github.com/strobelt/ofxparser.netcore).
- OFX entities classes inspired from [Aspose.Finance](https://products.aspose.com/finance/net/) package.
- Inital implementation cloned from [strobelt/ofxparser.netcore](https://github.com/strobelt/ofxparser.netcore).
- OFX entities classes inspired from [Aspose.Finance](https://products.aspose.com/finance/net/) package.

## License
**OFX-Tool** is available under the MIT license. See the LICENSE file for more info.

0 comments on commit 058cd01

Please sign in to comment.