-
Notifications
You must be signed in to change notification settings - Fork 299
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
Code metrics moving and redesign #3934
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; two questions.
{ | ||
internal abstract class CodeMetricResultBase : ICodeMetricResult | ||
{ | ||
public CodeMetricResultBase(Declaration declaration, CodeMetric metric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it weird to have a internal
class that contains a public
ctor?
|
||
public override IEnumerable<ICodeMetricResult> Results() => new[] { new LineCountModuleMetricResult(_finder.ModuleDeclaration(_qmn), ownerReference, workingValue) }; | ||
|
||
public override void EnterEndOfLine([NotNull] VBAParser.EndOfLineContext _) => workingValue++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we wanna to count blank and comment lines? Or better, enhance to return a struct
with counts of each types Declarations
, Blank
, Comment line
, and Module body line
with a total?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm ... the current design doesn't really support anything that closely coupled and rich as result type.
Most notably it can only really represent strings properly.
Each of these can be spawning their own result type though ...
bd90b4a
to
32ddfda
Compare
15197ef
to
f0b7c98
Compare
{ | ||
try | ||
{ | ||
return (CodeMetric)Activator.CreateInstance(t, new object[] { }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda want a cleaner way than instantiating these at registration time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you not just register all the code metrics with CodeMetric
? Then the collection of all of them will be registered with IEnumerable<CodeMetric>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that before, it didn't work :/
} | ||
container.Register(Component.For<ICodeMetricsAnalyst>() | ||
.ImplementedBy<CodeMetricsAnalyst>() | ||
.DependsOn(Dependency.OnValue<IEnumerable<CodeMetric>>(metricImplementations)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a rare case of explicit dependency configuration. Is that okay?
Also move a ton of other stuff around and cowboy a design for the CodeMetrics overhaul
This implements each CodeMetric in it's own separate class-collection and ParseTreeListener For now only Cyclomatic Complexity is implemented as a Proof Of Concept
…ies into baseclass
…ser with using-block
this should allow implementation of a proper UI. Do note that the interface of the VM is basically guesswork to how this works best.
…d ClassId on IDockableUserControl
…d ClassId on IDockableUserControl
1e2f71f
to
3aac9ae
Compare
@@ -53,7 +55,6 @@ private void UpdateInspectionSeverity(Configuration config) | |||
if (inspection.Name == setting.Name) | |||
{ | |||
inspection.Severity = setting.Severity; | |||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a break
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't even know where this is coming from ... let me investigate that bit of change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to have been added on next with commit 459d322 ... :cough:
get => _selectedItem; | ||
set | ||
{ | ||
_selectedItem = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if value == _selectedItem
, we're firing extraneous PropertyChanged
events here.
@@ -8,8 +9,8 @@ namespace Rubberduck.UI.CodeExplorer | |||
[ExcludeFromCodeCoverage] | |||
public partial class CodeExplorerWindow : UserControl, IDockableUserControl | |||
{ | |||
private const string ClassId = "C5318B59-172F-417C-88E3-B377CDA2D809"; | |||
string IDockableUserControl.ClassId { get { return ClassId; } } | |||
private readonly string RandomGuid = Guid.NewGuid().ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☠️ makes me wonder what the purpose of IDockableUserControl.GuidIdentifier
really is... do we really need this?
{ | ||
get { return "BFD04A86-CACA-4F95-9656-A0BF7D3AE254"; } | ||
} | ||
private readonly string RandomGuid = Guid.NewGuid().ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do need a GUID, then why can't it be a RubberduckGuid
constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular GUID is just used as an unique identifier for an instance created by the CreateToolWindow
, as per documentation for GuidPosition
parameter.
{ | ||
var signature = $"{GetMethodType(member)} {member.IdentifierName}({string.Join(", ", GetMemberParameters(member))})"; | ||
|
||
return member.AsTypeName == null ? signature : $"{signature} As {member.AsTypeName}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempted to swap As
for {Tokens.As}
here 😉
return new List<Parameter>(); | ||
} | ||
|
||
if (GetMethodType(member) == "Property Get") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels wrong when the method returns $"{Tokens.Property} {Tokens.Get}"
, would prefer to have string interpolation here too... but why can we assume parameters.Count
is >= 1 here? Most Property Get
members are parameterless... 😕
The following things are done:
Rubberduck.Inspections
toRubberduck.CodeAnalysis
Rubberduck.Core
intoRubberduck.CodeAnalysis
TBD:
See #3862 for a bit of background, as well as #403 and #3522's review comments for why this is done