Skip to content

Commit 4a62531

Browse files
committed
Adkust based on SonarCloud
1 parent 09077e8 commit 4a62531

File tree

11 files changed

+62
-17
lines changed

11 files changed

+62
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nanoFramework.System.IO.Ports&metric=alert_status)](https://sonarcloud.io/dashboard?id=nanoFramework.System.IO.Ports) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=nanoFramework.System.IO.Ports&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=nanoFramework.System.IO.Ports) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) [![NuGet](https://img.shields.io/nuget/dt/nanoFramework.System.IO.Ports.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.System.IO.Ports/) [![#yourfirstpr](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](https://github.com/nanoframework/Home/blob/master/CONTRIBUTING.md)[![Discord](https://img.shields.io/discord/478725473862549535.svg?logo=discord&logoColor=white&label=Discord&color=7289DA)](https://discord.gg/gCyBu8T)
1+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nanoframework_System.IO.Ports&metric=alert_status)](https://sonarcloud.io/dashboard?id=nanoframework_System.IO.Ports) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=nanoframework_System.IO.Ports&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=nanoframework_System.IO.Ports) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) [![NuGet](https://img.shields.io/nuget/dt/nanoFramework.System.IO.Ports.svg?label=NuGet&style=flat&logo=nuget)](https://www.nuget.org/packages/nanoFramework.System.IO.Ports/) [![#yourfirstpr](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](https://github.com/nanoframework/Home/blob/master/CONTRIBUTING.md) [![Discord](https://img.shields.io/discord/478725473862549535.svg?logo=discord&logoColor=white&label=Discord&color=7289DA)](https://discord.gg/gCyBu8T)
22

33
![nanoFramework logo](https://github.com/nanoframework/Home/blob/master/resources/logo/nanoFramework-repo-logo.png)
44

System.IO.Ports/Parity.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
namespace System.IO.Ports
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace System.IO.Ports
27
{
38
/// <summary>
49
/// Specifies the parity bit for a System.IO.Ports.SerialPort object.

System.IO.Ports/SerialData.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-

1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
26
namespace System.IO.Ports
37
{
48
/// <summary>

System.IO.Ports/SerialDataReceivedEventArgs.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
namespace System.IO.Ports
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace System.IO.Ports
27
{
38
/// <summary>
49
/// Provides data for the System.IO.Ports.SerialPort.DataReceived event.
510
/// </summary>
611
public class SerialDataReceivedEventArgs : EventArgs
712
{
8-
SerialData _data;
13+
private readonly SerialData _data;
914

1015
internal SerialDataReceivedEventArgs(SerialData eventCode)
1116
{

System.IO.Ports/SerialDataReceivedEventHandler.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
namespace System.IO.Ports
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace System.IO.Ports
27
{
38
/// <summary>
49
/// Represents the method that will handle the System.IO.Ports.SerialPort.DataReceived

System.IO.Ports/SerialDeviceEventListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace System.IO.Ports
1212
internal class SerialDeviceEventListener : IEventProcessor, IEventListener
1313
{
1414
// Map of serial device numbers to SerialDevice objects.
15-
private ArrayList _serialDevicesMap = new ArrayList();
15+
private readonly ArrayList _serialDevicesMap = new ArrayList();
1616

1717
public SerialDeviceEventListener()
1818
{

System.IO.Ports/SerialMode.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-

1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
26
namespace System.IO.Ports
37
{
48
/// <summary>

System.IO.Ports/SerialPort.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-

1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
26
using System.Runtime.CompilerServices;
37
using System.Text;
48
using System.Collections;
@@ -38,7 +42,7 @@ public class SerialPort : IDisposable
3842
private char _watchChar;
3943
private SerialDataReceivedEventHandler _callbacksDataReceivedEvent = null;
4044
private SerialStream _stream;
41-
private object _syncLock;
45+
private readonly object _syncLock;
4246
private string _newLine;
4347
private bool _hasBeenOpened = false;
4448

@@ -270,7 +274,7 @@ public StopBits StopBits
270274
/// Gets or sets the port for communications, including but not limited to all available
271275
/// COM ports.
272276
/// </summary>
273-
/// <exception cref=ArgumentException"">The System.IO.Ports.SerialPort.PortName property was set to a value with a length
277+
/// <exception cref="ArgumentException">The System.IO.Ports.SerialPort.PortName property was set to a value with a length
274278
/// of zero. -or- The System.IO.Ports.SerialPort.PortName property was set to a value
275279
/// that starts with "\\". -or- The port name was not valid.</exception>
276280
/// <exception cref="ArgumentNullException">The System.IO.Ports.SerialPort.PortName property was set to null.</exception>
@@ -611,8 +615,8 @@ public string ReadExisting()
611615
}
612616

613617
byte[] toRead = new byte[BytesToRead];
614-
var ret = NativeRead(toRead, 0, toRead.Length);
615-
// normally ret == toRead.Length
618+
NativeRead(toRead, 0, toRead.Length);
619+
// An exception is thrown if timeout, so we are sure to read only 1 byte properly
616620
return Encoding.GetString(toRead, 0, toRead.Length);
617621
}
618622

@@ -837,6 +841,9 @@ protected void Dispose(bool disposing)
837841
}
838842
}
839843

844+
/// <summary>
845+
/// Dispose the Serial Port
846+
/// </summary>
840847
public void Dispose()
841848
{
842849
lock (_syncLock)

System.IO.Ports/SerialStream.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
using System;
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
using System;
27
using System.Text;
38

49
namespace System.IO.Ports
510
{
611
internal class SerialStream : Stream
712
{
8-
private SerialPort _serial;
13+
private readonly SerialPort _serial;
914

1015
internal SerialStream(SerialPort serial)
1116
{

System.IO.Ports/StopBits.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
namespace System.IO.Ports
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace System.IO.Ports
27
{
38
/// <summary>
49
/// Specifies the number of stop bits used on the System.IO.Ports.SerialPort object.

0 commit comments

Comments
 (0)