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 #3522

Merged
merged 28 commits into from Nov 28, 2017

Conversation

Projects
None yet
5 participants
@Vogel612
Member

Vogel612 commented Oct 28, 2017

See #403

Current Status of the UI:

Code Metrics dockable presenter

The columns resize together.

@Vogel612 Vogel612 changed the title from Code Metrics (WIP - Backend finished) to Code Metrics Nov 24, 2017

@bclothier

Small suggestions, notable are throw which could crash the runtime; LTGM otherwise.

@@ -221,7 +221,9 @@ private void Startup()
catch (Exception e)
{
_logger.Log(LogLevel.Fatal, e, "Startup sequence threw an unexpected exception.");
//throw; // <<~ uncomment to crash the process
#if DEBUG
throw; // <<~ uncomment to crash the process

This comment has been minimized.

@bclothier

bclothier Nov 24, 2017

Contributor

IMO, I'd remove the comment altogether. Or put in the "start a WW III" comment instead.

@bclothier

bclothier Nov 24, 2017

Contributor

IMO, I'd remove the comment altogether. Or put in the "start a WW III" comment instead.

This comment has been minimized.

@Vogel612

Vogel612 Nov 24, 2017

Member

That's the throw discussed in #3563

@Vogel612

Vogel612 Nov 24, 2017

Member

That's the throw discussed in #3563

private ModuleMetricsResult GetModuleResult(QualifiedModuleName qmn, IParseTree moduleTree, DeclarationFinder declarationFinder)
{
// Consider rewrite as visitor? That should make subtrees easier and allow us to expand metrics

This comment has been minimized.

@bclothier

bclothier Nov 24, 2017

Contributor

Note that a visitor can be cancelled whether a walker can't be as easily cancelled. That may have some UI ramifications if there can be a delay when interacting with the UI. If it executes quickly and UI is responsive, then it might be just be fine as a walker.

@bclothier

bclothier Nov 24, 2017

Contributor

Note that a visitor can be cancelled whether a walker can't be as easily cancelled. That may have some UI ramifications if there can be a delay when interacting with the UI. If it executes quickly and UI is responsive, then it might be just be fine as a walker.

This comment has been minimized.

@Vogel612

Vogel612 Nov 24, 2017

Member

sure can be. Just check a CancellationToken when entering any rule. Bit of a pain though, so this usually isn't done...

@Vogel612

Vogel612 Nov 24, 2017

Member

sure can be. Just check a CancellationToken when entering any rule. Bit of a pain though, so this usually isn't done...

Show outdated Hide outdated RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsViewModel.cs
Show outdated Hide outdated RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsViewModel.cs
Show outdated Hide outdated RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsViewModel.cs
Show outdated Hide outdated Rubberduck.Parsing/VBA/RubberduckParserState.cs
{
public struct CodeMetricsResult
{
public CodeMetricsResult(int lines, int cyclomaticComplexity, int nesting)

This comment has been minimized.

@MDoerner

MDoerner Nov 25, 2017

Contributor

Why are we hard-coding the types of code metrics we support?

@MDoerner

MDoerner Nov 25, 2017

Contributor

Why are we hard-coding the types of code metrics we support?

This comment has been minimized.

@Vogel612

Vogel612 Nov 25, 2017

Member

because aggregation may follow different rules depending on the metric. Since that's the case, we'd need to accomodate an aggregation in all kinds of metrics.

Last but not least this seemed like the least effort. This PR is "only" a first iteration of the feature, and future iterations may well change this. But I don't think we can reasonably expect user-contributed code-metrics. It's just not something I think we're going to need.

@Vogel612

Vogel612 Nov 25, 2017

Member

because aggregation may follow different rules depending on the metric. Since that's the case, we'd need to accomodate an aggregation in all kinds of metrics.

Last but not least this seemed like the least effort. This PR is "only" a first iteration of the feature, and future iterations may well change this. But I don't think we can reasonably expect user-contributed code-metrics. It's just not something I think we're going to need.

}
private class CodeMetricsListener : VBAParserBaseListener

This comment has been minimized.

@MDoerner

MDoerner Nov 25, 2017

Contributor

Why is there only one listener for all three types of code metrics? Wouldn't it be better to have one for each type and then just combine them for the walk over the tree?

@MDoerner

MDoerner Nov 25, 2017

Contributor

Why is there only one listener for all three types of code metrics? Wouldn't it be better to have one for each type and then just combine them for the walk over the tree?

This comment has been minimized.

@Vogel612

Vogel612 Nov 25, 2017

Member

Same reasoning as above. In principle the idea is correct, it seemed like too much of a hassle for something we'd probably not need.

@Vogel612

Vogel612 Nov 25, 2017

Member

Same reasoning as above. In principle the idea is correct, it seemed like too much of a hassle for something we'd probably not need.

Show outdated Hide outdated RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsViewModel.cs
Show outdated Hide outdated RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsViewModel.cs
: base(command)
{
}
public override bool EvaluateCanExecute(RubberduckParserState state) => true;

This comment has been minimized.

@Hosch250

Hosch250 Nov 26, 2017

Member

Pretty sure true is the default state.

@Hosch250

Hosch250 Nov 26, 2017

Member

Pretty sure true is the default state.

This comment has been minimized.

@Vogel612

Vogel612 Nov 26, 2017

Member

it isn't. The default state is state != null && (_command?.CanExecute(state) ?? false);. Since that's all irrelevant for showing a docked window it's overriden here

@Vogel612

Vogel612 Nov 26, 2017

Member

it isn't. The default state is state != null && (_command?.CanExecute(state) ?? false);. Since that's all irrelevant for showing a docked window it's overriden here

Show outdated Hide outdated RetailCoder.VBE/UI/Converters/SubractionConverter.cs

@retailcoder retailcoder merged commit a4d6173 into rubberduck-vba:next Nov 28, 2017

1 check passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@Vogel612 Vogel612 deleted the Vogel612:code-metrics branch Dec 9, 2017

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