Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qodana fixes #2221

Merged
merged 11 commits into from
Aug 17, 2023
11 changes: 5 additions & 6 deletions Src/FluentAssertions/Common/NullConfigurationStore.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
namespace FluentAssertions.Common
namespace FluentAssertions.Common;

internal class NullConfigurationStore : IConfigurationStore
{
jnyrup marked this conversation as resolved.
Show resolved Hide resolved
internal class NullConfigurationStore : IConfigurationStore
public string GetSetting(string name)
{
public string GetSetting(string name)
{
return string.Empty;
}
return string.Empty;
}
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Formatting/DefaultValueFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DefaultValueFormatter : IValueFormatter
/// The number of spaces to indent the members of this object by.
/// </summary>
/// <remarks>The default value is 3.</remarks>
protected virtual int SpacesPerIndentionLevel { get; } = 3;
protected virtual int SpacesPerIndentionLevel => 3;

/// <summary>
/// Determines whether this instance can handle the specified value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DictionaryValueFormatter : IValueFormatter
/// The number of items to include when formatting this object.
/// </summary>
/// <remarks>The default value is 32.</remarks>
protected virtual int MaxItems { get; } = 32;
protected virtual int MaxItems => 32;

/// <summary>
/// Indicates whether the current <see cref="IValueFormatter"/> can handle the specified <paramref name="value"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class EnumerableValueFormatter : IValueFormatter
/// The number of items to include when formatting this object.
/// </summary>
/// <remarks>The default value is 32.</remarks>
protected virtual int MaxItems { get; } = 32;
protected virtual int MaxItems => 32;

/// <summary>
/// Indicates whether the current <see cref="IValueFormatter"/> can handle the specified <paramref name="value"/>.
Expand Down
2 changes: 1 addition & 1 deletion Tests/FluentAssertions.Equivalency.Specs/BasicSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public void When_threating_open_type_as_value_type_and_a_closed_type_as_referenc
act.Should().NotThrow();
}

private struct Option<T> : IEquatable<Option<T>>
private readonly struct Option<T> : IEquatable<Option<T>>
where T : class
{
public T Value { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2674,8 +2674,6 @@ private class ClassWithNonBrowsableMembers

private class ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable
{
public int BrowsableField = -1;
jnyrup marked this conversation as resolved.
Show resolved Hide resolved

public int BrowsableProperty { get; set; }

public int FieldThatMightBeNonBrowsable = -1;
Expand All @@ -2685,8 +2683,6 @@ private class ClassWhereMemberThatCouldBeNonBrowsableIsBrowsable

private class ClassWhereMemberThatCouldBeNonBrowsableIsNonBrowsable
{
public int BrowsableField = -1;

public int BrowsableProperty { get; set; }

[EditorBrowsable(EditorBrowsableState.Never)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public class Foo
{
public string Field = "bar";

public string Bar { get; } = "bar";
public string Bar => "bar";

public string BarMethod() => Bar;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,7 @@ public void Should_throw_a_helpful_error_when_accidentally_using_equals_with_a_r
DateTimeOffset someDateTimeOffset = new(2022, 9, 25, 13, 48, 42, 0, TimeSpan.Zero);

// Act
Action action = () => someDateTimeOffset.Should().BeLessThan(0.Seconds()).Equals(someDateTimeOffset);
var action = () => someDateTimeOffset.Should().BeLessThan(0.Seconds()).Equals(null);

// Assert
action.Should().Throw<NotSupportedException>()
Expand Down Expand Up @@ -2587,7 +2587,7 @@ public void Should_throw_a_helpful_error_when_accidentally_using_equals()
DateTimeOffset someDateTimeOffset = new(2022, 9, 25, 13, 48, 42, 0, TimeSpan.Zero);

// Act
Action action = () => someDateTimeOffset.Should().Equals(someDateTimeOffset);
var action = () => someDateTimeOffset.Should().Equals(null);

// Assert
action.Should().Throw<NotSupportedException>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ public void Should_throw_a_helpful_error_when_accidentally_using_equals()
MyEnum? subject = null;

// Act
Action action = () => subject.Should().Equals(subject);
var action = () => subject.Should().Equals(null);

// Assert
action.Should().Throw<NotSupportedException>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ public void Should_throw_a_helpful_error_when_accidentally_using_equals()
var someObject = new Exception();

// Act
Action action = () => someObject.Should().Equals(someObject);
var action = () => someObject.Should().Equals(null);

// Assert
action.Should().Throw<NotSupportedException>()
Expand Down Expand Up @@ -1394,8 +1394,8 @@ public class SerializableClassWithNonSerializableMember

public string NonSerializable
{
get { return nonSerializable; }
set { nonSerializable = value; }
get => nonSerializable;
set => nonSerializable = value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ public void Should_throw_a_helpful_error_when_accidentally_using_equals()
TimeOnly someTimeOnly = new(21, 1);

// Act
Action act = () => someTimeOnly.Should().Equals(someTimeOnly);
var act = () => someTimeOnly.Should().Equals(null);

// Assert
act.Should().Throw<NotSupportedException>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ public void When_asserting_execution_time_of_null_action_it_should_throw()
object subject = null;

// Act
Action act = () => subject.ExecutionTimeOf(s => s.ToString()).Should().BeLessThan(1.Days());
var act = () => subject.ExecutionTimeOf(s => s.ToString()).Should().BeLessThan(1.Days());

// Assert
act.Should().ThrowExactly<ArgumentNullException>()
Expand Down Expand Up @@ -626,7 +626,7 @@ public void When_accidentally_using_equals_it_should_throw_a_helpful_error()
var subject = new object();

// Act
Action act = () => subject.ExecutionTimeOf(s => s.ToString()).Should().Equals(1.Seconds());
var act = () => subject.ExecutionTimeOf(s => s.ToString()).Should().Equals(1.Seconds());

// Assert
act.Should().Throw<NotSupportedException>().WithMessage(
Expand Down
4 changes: 2 additions & 2 deletions Tests/FluentAssertions.Specs/Types/MethodInfoSelectorSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void When_method_info_selector_is_null_then_should_should_throw()
MethodInfoSelector methodInfoSelector = null;

// Act
Action act = () => methodInfoSelector.Should();
var act = () => methodInfoSelector.Should();

// Assert
act.Should().ThrowExactly<ArgumentNullException>()
Expand Down Expand Up @@ -433,7 +433,7 @@ public void When_accidentally_using_equals_it_should_throw_a_helpful_error()
Type type = typeof(TestClassForMethodSelector);

// Act
Action action = () => type.Methods().Should().Equals(null);
var action = () => type.Methods().Should().Equals(null);

// Assert
action.Should().Throw<NotSupportedException>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void When_asserting_properties_are_virtual_and_they_are_it_should_succeed
var propertyInfoSelector = new PropertyInfoSelector(typeof(ClassWithAllPropertiesVirtual));

// Act
Action act = () =>
var act = () =>
propertyInfoSelector.Should().BeVirtual();

// Assert
Expand Down Expand Up @@ -298,7 +298,7 @@ public void When_accidentally_using_equals_it_should_throw_a_helpful_error()
var someObject = new PropertyInfoSelectorAssertions();

// Act
Action action = () => someObject.Equals(someObject);
var action = () => someObject.Equals(null);

// Assert
action.Should().Throw<NotSupportedException>()
Expand All @@ -313,7 +313,7 @@ internal class ClassWithAllPropertiesVirtual
{
public virtual string PublicVirtualProperty { set { } }

internal virtual string InternalVirtualProperty { get { return null; } }
internal virtual string InternalVirtualProperty => null;

protected virtual string ProtectedVirtualProperty { get; set; }
}
Expand All @@ -334,20 +334,20 @@ internal class ClassWithNonVirtualPublicProperties : IInterfaceWithProperty

internal class ClassWithReadOnlyProperties
{
public string ReadOnlyProperty { get { return ""; } }
public string ReadOnlyProperty => "";

public string ReadOnlyProperty2 { get { return ""; } }
public string ReadOnlyProperty2 => "";

public string ReadWriteProperty { get { return ""; } set { } }
public string ReadWriteProperty { get => ""; set { } }
}

internal class ClassWithWritableProperties
{
public string ReadOnlyProperty { get { return ""; } }
public string ReadOnlyProperty => "";

public string ReadWriteProperty { get { return ""; } set { } }
public string ReadWriteProperty { get => ""; set { } }

public string ReadWriteProperty2 { get { return ""; } set { } }
public string ReadWriteProperty2 { get => ""; set { } }
}

internal class ClassWithOnlyWritableProperties
Expand All @@ -357,9 +357,9 @@ internal class ClassWithOnlyWritableProperties

internal class ClassWithOnlyReadOnlyProperties
{
public string ReadOnlyProperty { get { return ""; } }
public string ReadOnlyProperty => "";

public string ReadOnlyProperty2 { get { return ""; } }
public string ReadOnlyProperty2 => "";
}

internal class ClassWithAllPropertiesDecoratedWithDummyAttribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ public void When_accidentally_using_equals_it_should_throw_a_helpful_error()
});

// Act
Action action = () => types.Should().Equals(types);
var action = () => types.Should().Equals(null);

// Assert
action.Should().Throw<NotSupportedException>()
Expand Down
10 changes: 3 additions & 7 deletions Tests/FluentAssertions.Specs/Types/TypeSelectorSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void When_type_selector_is_null_then_should_should_throw()
TypeSelector propertyInfoSelector = null;

// Act
Action act = () => propertyInfoSelector.Should();
var act = () => propertyInfoSelector.Should();

// Assert
act.Should().ThrowExactly<ArgumentNullException>()
Expand Down Expand Up @@ -924,17 +924,13 @@ internal struct InternalStructValueType
{
}

internal record struct InternalRecordStructValueType
{
}
internal record struct InternalRecordStructValueType;

internal class InternalClassNotValueType
{
}

internal record class InternalRecordClass
{
}
internal record class InternalRecordClass;

internal enum InternalEnumValueType
{
Expand Down
6 changes: 6 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ dotnet:
exclude:
- name: ConvertIfStatementToReturnStatement
- name: ConvertIfStatementToConditionalTernaryExpression
- name: All
paths:
- Build
- Tests/AssemblyA
- Tests/AssemblyB
- Tests/Benchmarks