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

Rule S1200: Classes should not be coupled to too many other classes #548

Merged
merged 4 commits into from
Jul 11, 2017

Conversation

Evangelink
Copy link
Contributor

Fix #515

Amaury Levé added 3 commits July 7, 2017 15:00
Copy link
Contributor

@valhristov valhristov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, few minor comments

KnownType.System_Single,
KnownType.System_Double,
KnownType.System_String,
KnownType.System_Object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does FxCop count other special types, such as Func and Action? What about Task?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, perhaps worth excluding all special types

Copy link
Contributor Author

@Evangelink Evangelink Jul 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a test for fields and Task, Action and Func do count. I will update my tests to see if I correctly handle them (should be good). Any idea of other special types? Pointers don't count as they are of basic types.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope.

.SelectMany(node => ExtractTypeSymbolsFromSyntaxNode(node, model));
}

private static IEnumerable<ITypeSymbol> ExtractTypeSymbolsFromSyntaxNode(SyntaxNode node, SemanticModel model)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps if you use yield return in this method the code will look better: less created arrays, no need to return null in some cases (e.g. when parameter.Type == null), etc.

KnownType.System_Single,
KnownType.System_Double,
KnownType.System_String,
KnownType.System_Object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, perhaps worth excluding all special types

{
var classDeclaration = (ClassDeclarationSyntax)c.Node;

if (c.IsTest() ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rspec doesn't say test are excluded, please update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot update a sub-task on RSPEC.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then flag it to PMs and let them handle it.

{
return parameter.Type != null
? new[] { model.GetSymbolInfo(parameter.Type).Symbol as ITypeSymbol }
: new[] { (ITypeSymbol)null };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer default(ITypeSymbol), but it's not worth to change it now - more a comment for future.

public abstract class TestCases // Noncompliant {{Split this class into smaller and more specialized ones to reduce its dependencies on other classes from 7 to the maximum authorized 1 or less.}}
// ^^^^^^^^^
{
// ================================================================================
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit funny formatting :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a pain to read the different parts when I was doing my tests. I could actually remove the sections now if you guys want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me to leave it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants