Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class _SizeColumn extends ColumnData<DiffClassData> {
_SizeColumn(this.dataPart, this.sizeType)
: super(
columnTitle(dataPart),
titleTooltip: columnTooltip(dataPart),
fixedWidthPx: 80.0,
alignment: ColumnAlignment.right,
);
Expand All @@ -183,6 +184,24 @@ class _SizeColumn extends ColumnData<DiffClassData> {
}
}

static String columnTooltip(_DataPart dataPart) {
switch (dataPart) {
case _DataPart.created:
return 'Size of this class allocated between the two snapshots.\n'
'This is the value for this row, not a cumulative total.';
case _DataPart.deleted:
return 'Size of this class released between the two snapshots.\n'
'This is the value for this row, not a cumulative total.';
case _DataPart.delta:
return 'Net size change of this class between the two snapshots '
'(allocated minus freed).\n'
'This is the value for this row, not a cumulative total.';
case _DataPart.persisted:
return 'Size of this class present in both snapshots.\n'
'This is the value for this row, not a cumulative total.';
}
}
Comment on lines +187 to +203

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

[CONCERN] The string literal '\nThis is the value for this row, not a cumulative total.' is repeated four times within the columnTooltip method. To adhere to the DRY principle and the repository style guide, this repeated sub-expression should be extracted into a local constant.

  static String columnTooltip(_DataPart dataPart) {
    const rowValueNote = '\\nThis is the value for this row, not a cumulative total.';
    switch (dataPart) {
      case _DataPart.created:
        return 'Size of this class allocated between the two snapshots.$rowValueNote';
      case _DataPart.deleted:
        return 'Size of this class released between the two snapshots.$rowValueNote';
      case _DataPart.delta:
        return 'Net size change of this class between the two snapshots '
            '(allocated minus freed).$rowValueNote';
      case _DataPart.persisted:
        return 'Size of this class present in both snapshots.$rowValueNote';
    }
  }
References
  1. Extract repeated sub-expressions or string literals within the same method into local variables or constants to adhere to the DRY principle. (link)


@override
int getValue(DiffClassData data) {
switch (sizeType) {
Expand Down
3 changes: 3 additions & 0 deletions packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ TODO: Remove this section if there are not any updates.
## Memory updates

* Added the ability to pin classes to the top of the Profile Memory table. [#8898](https://github.com/flutter/devtools/issues/8898)
* Clarified that Diff Snapshots size columns (Allocated, Freed, Delta, Persisted)
show memory for that class row, not a running total of the table.
[#8837](https://github.com/flutter/devtools/issues/8837)

## Debugger updates

Expand Down