Skip to content

Commit

Permalink
Display SonarDelphi errors instead of failing scan
Browse files Browse the repository at this point in the history
  • Loading branch information
fourls committed Oct 10, 2024
1 parent 0ae580f commit 01eac33
Show file tree
Hide file tree
Showing 17 changed files with 985 additions and 38 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

* View Last Analysis Log option in the main DelphiLint window, which displays the analysis logs produced by SonarDelphi
for the most recent analysis.
* Status indicator in the main DelphiLint window, which prominently displays whether errors or warnings have been
produced in the most recent analysis.

### Changed

* Project Options now prevents a blank server URL or project key when in Connected Mode.
* The default SonarDelphi version is now [1.8.0](https://github.com/integrated-application-development/sonar-delphi/releases/tag/v1.8.0).
* DelphiLint no longer treats SonarDelphi analysis errors as fatal errors, supporting partial analysis in much the
same way as a normal SonarDelphi scan.

### Fixed

Expand Down
5 changes: 3 additions & 2 deletions client/source/DelphiLint.Analyzer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TAnalyzerImpl = class(TInterfacedObject, IAnalyzer)
FOnAnalysisStateChanged: TEventNotifier<TAnalysisStateChangeContext>;
FServerTerminateEvent: TEvent;

procedure OnAnalyzeResult(Issues: TObjectList<TLintIssue>);
procedure OnAnalyzeResult(Issues: TObjectList<TLintIssue>; LogMessages: TArray<string>);
procedure OnAnalyzeError(Message: string);
procedure SaveIssues(Issues: TObjectList<TLintIssue>; IssuesHaveMetadata: Boolean = False);
function TryRefreshRules: Boolean;
Expand Down Expand Up @@ -432,7 +432,7 @@ procedure TAnalyzerImpl.OnAnalyzeError(Message: string);

//______________________________________________________________________________________________________________________

procedure TAnalyzerImpl.OnAnalyzeResult(Issues: TObjectList<TLintIssue>);
procedure TAnalyzerImpl.OnAnalyzeResult(Issues: TObjectList<TLintIssue>; LogMessages: TArray<string>);
var
HasMetadata: Boolean;
ProjectFile: string;
Expand Down Expand Up @@ -461,6 +461,7 @@ procedure TAnalyzerImpl.OnAnalyzeResult(Issues: TObjectList<TLintIssue>);
end;

StateChange.Files := FCurrentAnalysis.Paths;
StateChange.LogMessages := LogMessages;
StateChange.Change := ascSucceeded;
FreeAndNil(FCurrentAnalysis);
FOnAnalysisStateChanged.Notify(StateChange);
Expand Down
1 change: 1 addition & 0 deletions client/source/DelphiLint.Context.pas
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface

TAnalysisStateChangeContext = record
Files: TArray<string>;
LogMessages: TArray<string>;
Change: TAnalysisStateChange;
end;

Expand Down
2 changes: 2 additions & 0 deletions client/source/DelphiLint.ExternalConsts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface
CReleasesApiUrl = 'https://api.github.com/repos/integrated-application-development/sonar-delphi/releases';
CFaqUrl = 'https://github.com/integrated-application-development/delphilint/blob/master/docs/FAQ.md';
CTokenInfoUrl = CFaqUrl + '#how-do-i-authenticate-with-a-sonarqube-instance-in-connected-mode';
CSonarDelphiUrl = 'https://github.com/integrated-application-development/sonar-delphi';
CReportSonarDelphiIssueUrl = CSonarDelphiUrl + '/issues/new?assignees=&labels=bug%2Ctriage&template=bug_report.yml';

implementation

Expand Down
272 changes: 272 additions & 0 deletions client/source/DelphiLint.LogViewer.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
object LogViewerForm: TLogViewerForm
Left = 0
Top = 0
Caption = 'Analysis Log'
ClientHeight = 434
ClientWidth = 892
Color = clBtnFace
Constraints.MinHeight = 300
Constraints.MinWidth = 755
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Segoe UI'
Font.Style = []
FormStyle = fsStayOnTop
TextHeight = 15
object BottomPanel: TPanel
Left = 0
Top = 389
Width = 892
Height = 45
Align = alBottom
TabOrder = 0
object Label3: TLabel
Left = 8
Top = 6
Width = 718
Height = 15
Caption =
'Please note that errors or warnings during an analysis can affect ' +
'the quality of the results, including false positive or false negative ' +
'issues.'
end
object Label4: TLabel
Left = 8
Top = 24
Width = 592
Height = 15
Caption =
'Errors are usually caused by attempting to analyze an invalid file ' +
'or by misconfiguring a sonar-project.properties.'
end
end
object LogListBox: TListBox
Left = 0
Top = 37
Width = 892
Height = 352
Style = lbOwnerDrawVariable
Align = alClient
BevelInner = bvLowered
BevelOuter = bvNone
BorderStyle = bsNone
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Consolas'
Font.Style = []
ItemHeight = 14
MultiSelect = True
ParentFont = False
PopupMenu = LogPopup
TabOrder = 1
StyleElements = [seBorder]
OnDrawItem = LogListBoxDrawItem
OnMeasureItem = LogListBoxMeasureItem
end
object TopPanel: TPanel
Left = 0
Top = 0
Width = 892
Height = 37
Align = alTop
TabOrder = 2
DesignSize = (
892
37)
object TitleLabel: TLabel
Left = 10
Top = 11
Width = 182
Height = 15
Caption = 'HH:MM analysis - SonarDelphi log'
end
object ReportButton: TBitBtn
Left = 720
Top = 6
Width = 165
Height = 25
Anchors = [akTop, akRight]
Caption = 'Report a bug on GitHub'
ImageIndex = 0
Images = IconImageList
TabOrder = 0
OnClick = ReportButtonClick
end
object SaveButton: TButton
Left = 617
Top = 6
Width = 97
Height = 25
Anchors = [akTop, akRight]
Caption = 'Save log file'
TabOrder = 1
OnClick = SaveButtonClick
end
end
object SaveDialog: TSaveTextFileDialog
DefaultExt = '.log'
Encodings.Strings = (
'UTF-8'
'ANSI'
'ASCII')
Left = 320
Top = 224
end
object IconImageList: TImageList
Left = 424
Top = 264
Bitmap = {
494C010101000800040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000001000000001002000000000000010
0000000000000000000000000000000000000000000000000000000000000000
000000000000B0AFAF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B0AFAF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000B0AF
AF002E2924002E292400FFFFFF00FFFFFF00FFFFFF00FFFFFF002E2924002E29
2400B0AFAF000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B0AFAF002E29
2400EBEBEA00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF002E2924002E29
24002E292400B0AFAF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000B0AFAF002E292400EBEB
EA00B0AFAF00B0AFAF00EBEBEA00FFFFFF00FFFFFF00EBEBEA002E2924002E29
24002E2924002E292400B0B0AF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000002E292400EBEBEA00B0AF
AF002E292400B0AFAF00EBEBEA00FFFFFF00FFFFFF00EBEBEA009B9A9A003D39
36002E2924002E2924002E292400000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000B0AFAF002E2924002E2924002E29
2400EBEBEA00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00EBEB
EA00767573002E2924002E292400B0AFAF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000002E2924002E2924002E292400DDDD
DC00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00EBEBEA002E2924002E2924002E2924000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000002E2924002E29240085848300FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00858483002E2924002E2924000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000002E2924002E29240085848300FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00858483002E2924002E2924000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000002E2924002E2924002E292400EBEB
EA00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00EBEBEA002E2924002E2924002E2924000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000B0AFAF002E2924002E292400B0AF
AF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00B0AFAF002E2924002E292400B0AFAF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000002E2924002E292400B0AF
AF00FFFFFF00FFFFFF00EBEBEA00FFFFFF00FFFFFF00EBEBEA00FFFFFF00FFFF
FF00B0AFAF002E2924002E292400000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000B0AFAF002E2924008584
8300B0AFAF00858483002E29240085848300858483002E29240085848300B0AF
AF00858483002E292400B0AFAF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B0AFAF002E29
24002E2924002E2924002E2924002E2924002E2924002E2924002E2924002E29
24002E292400B0AFAF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000B0AF
AF002E2924002E2924002E2924002E2924002E2924002E2924002E2924002E29
2400B0AFAF000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000B0AFAF002E2924002E2924002E2924002E292400B0AFAF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000424D3E000000000000003E000000
2800000040000000100000000100010000000000800000000000000000000000
000000000000000000000000FFFFFF00F81F000000000000E007000000000000
C003000000000000800100000000000080010000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000080010000000000008001000000000000C003000000000000
E007000000000000F81F00000000000000000000000000000000000000000000
000000000000}
end
object LogPopup: TPopupMenu
Left = 672
Top = 320
object CopyItem: TMenuItem
Caption = '&Copy'
OnClick = CopyItemClick
end
object SaveItem: TMenuItem
Caption = '&Save'
OnClick = SaveItemClick
end
end
end
Loading

0 comments on commit 01eac33

Please sign in to comment.