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

.NET support #37

Open
konbec opened this issue Feb 17, 2016 · 2 comments
Open

.NET support #37

konbec opened this issue Feb 17, 2016 · 2 comments

Comments

@konbec
Copy link

konbec commented Feb 17, 2016

Hello,
it is possible to adapt the plugin to support .NET code (C#, perhaps VB.NET)
Thank You in advance!

@pawlakm
Copy link
Member

pawlakm commented Feb 19, 2016

Hi,

Currently the CodeSmells plugin's behavior is tightly bound to Java annotations (with SOURCE retention policy) and provides a library made available through a Maven dependency in order to help you declare these annotations correctly and make sure that only allowed Smells types are declared.

Adapting the plugin to C# / VB.NET (or any other language) should be possible, however we need to:

  • Define how @smells must be declared in C# (comments instead of annotations ? other ?)
  • Define how and where possible Smells types are defined
  • Define if a violation must be raised if unexpected Smells types are used (or simply ignored)
  • Decide if we need to provide a library / dependency for declaring Smells (or use comments-based declaration instead)

Once these points are handled, we'll be able to work on the plugin itself :

  • the GUI -> no impact here at first sight (at least as long as we do not need to filter measures by language)
  • existing CodeSmell plugin core -> no impact here at first sight (at least as long as we do not need to filter measures by language)
  • create at least one rule that detects smells (based on annotations, comments, or whatever strategy that has been chosen) then creates corresponding issues -> unknown effort (I never wrote an extension for SonarQube C# nor VB.NET plugins)
  • create a measurer that detects, counts then aggregates different smells types in C# / VB.NET code then saves corresponding measures -> small effort if comment based (currently regexp based)

In any case, help will be required in order to make the plugin compatible with C# / VB.NET. If you're interested in contributing to such a new feature, do not hesitate to tell me !

@simkin2004
Copy link

"Define how @smells must be declared in C# (comments instead of annotations ? other ?)"
Java annotations are roughly equivalent to .NET attributes.

"Define how and where possible Smells types are defined"
https://msdn.microsoft.com/en-us/library/system.attributetargets(v=vs.110).aspx
I would suspect that you want to target everything.
.NET does not have the capability of targeting an attribute based on the context of the values provided. We would either need to write a special Code Smell Attribute for every code smell with the appropriate targets, and/or a generic code smell attribute that targets everything.

"Define if a violation must be raised if unexpected Smells types are used (or simply ignored)"
I would include the information necessary to appropriately render the unexpected Smell as part of the Attribute definition. Then as developers created "unexpected" smells, it would show on the reports and we could add an exclusion list to the rules to filter them out or disallow unknowns.

"Decide if we need to provide a library / dependency for declaring Smells (or use comments-based declaration instead)"
I believe attribute-based is more appropriate than comment-based, unless you are planning to include the smells in the documentation as well.

Could we create the .NET code scanner to match the Java version's output so that rules would not have to be rewritten?

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

No branches or pull requests

3 participants