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
48 changes: 48 additions & 0 deletions client/DelphiLintClientProjects250.groupproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{E13F5E64-5BEF-4919-9E81-0DFCBA69E1B4}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<Projects Include="source\DelphiLintClient250.dproj">
<Dependencies/>
</Projects>
<Projects Include="test\DelphiLintClientTest250.dproj">
<Dependencies/>
</Projects>
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>Default.Personality.12</Borland.Personality>
<Borland.ProjectType/>
<BorlandProject>
<Default.Personality/>
</BorlandProject>
</ProjectExtensions>
<Target Name="DelphiLintClient250">
<MSBuild Projects="source\DelphiLintClient250.dproj"/>
</Target>
<Target Name="DelphiLintClient250:Clean">
<MSBuild Projects="source\DelphiLintClient250.dproj" Targets="Clean"/>
</Target>
<Target Name="DelphiLintClient250:Make">
<MSBuild Projects="source\DelphiLintClient250.dproj" Targets="Make"/>
</Target>
<Target Name="DelphiLintClientTest250">
<MSBuild Projects="test\DelphiLintClientTest250.dproj"/>
</Target>
<Target Name="DelphiLintClientTest250:Clean">
<MSBuild Projects="test\DelphiLintClientTest250.dproj" Targets="Clean"/>
</Target>
<Target Name="DelphiLintClientTest250:Make">
<MSBuild Projects="test\DelphiLintClientTest250.dproj" Targets="Make"/>
</Target>
<Target Name="Build">
<CallTarget Targets="DelphiLintClient250;DelphiLintClientTest250"/>
</Target>
<Target Name="Clean">
<CallTarget Targets="DelphiLintClient250:Clean;DelphiLintClientTest250:Clean"/>
</Target>
<Target Name="Make">
<CallTarget Targets="DelphiLintClient250:Make;DelphiLintClientTest250:Make"/>
</Target>
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
</Project>
2 changes: 1 addition & 1 deletion client/source/DelphiLint.Analyzer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ procedure TAnalyzerImpl.AnalyzeFiles(const Files: TArray<string>; const ProjectF
end
else if not LintContext.Settings.StandaloneUseDefaultRules then begin
AnalyzeOptions.UseDefaultRules := False;
AnalyzeOptions.DisabledRules := SplitString(LintContext.Settings.StandaloneDisabledRules, ',');
AnalyzeOptions.DisabledRules := TArray<string>(SplitString(LintContext.Settings.StandaloneDisabledRules, ','));
end;

DoAnalyzeFiles(AnalyzeOptions, ProjectOptions.SonarHostDownloadPlugin);
Expand Down
2 changes: 1 addition & 1 deletion client/source/DelphiLint.FileLogger.pas
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ constructor TFileLogger.Create(LogPath: string);
FLock := TMutex.Create;

if not TFile.Exists(FLogPath) then begin
FreeAndNil(TFile.Create(FLogPath));
TFile.Create(FLogPath).Free;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of these changes?

end;
end;

Expand Down
4 changes: 2 additions & 2 deletions client/source/DelphiLint.Handlers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ destructor TEditorHandler.Destroy;
// Although these hooks are owned by the context menu, we need to free them when the plugin is disabled
for Hook in FPopupHooks.Values do begin
Hook.OnFreed.RemoveListener(OnHookFreed);
FreeAndNil(Hook);
Hook.Free;
end;
FreeAndNil(FPopupHooks);
FreeAndNil(FPopupHooks); // Remover?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What does this comment mean?


if ContextValid then begin
Analyzer.OnAnalysisStateChanged.RemoveListener(OnAnalysisStateChanged);
Expand Down
63 changes: 62 additions & 1 deletion client/source/DelphiLint.HtmlGen.pas
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,59 @@ function TRuleHtmlGenerator.GenerateRuleDescriptionHtml(Description: TRuleDescri
//______________________________________________________________________________________________________________________

function TRuleHtmlGenerator.BuildHtmlPage(BodyHtml: string; BodyClass: string): string;

function GetLegacyScript: string;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Webpack/Babel can polyfill for old IE versions (see client/jslib/webpack.config.js) so there's no need to include it ourselves. Could you identify the IE version you want to support and try configuring webpack to bundle for that version?

begin
Result :=
'function hasClass(element, className) {' +
' return element.className && element.className.indexOf(className) !== -1;' +
'}' +
'function addClass(element, className) {' +
' if (!hasClass(element, className)) { element.className += " " + className }' +
'}' +
'function removeClass(element, className) {' +
' if (!hasClass(element, className)) { return }' +
' element.className = element.className.replace(" " + className, "").replace(className, "");' +
'}' +
'function getElementsWithClass(className) {' +
' var elements = [];' +
' var allElements = document.getElementsByTagName("*");' +
' for (var i = 0; i < allElements.length; i++) {' +
' if (hasClass(allElements[i], className)) { elements.push(allElements[i]) }' +
' }' +
' return elements;' +
'}' +
'function highlightTag(tagName) {' +
' var preElements = document.getElementsByTagName(tagName);' +
' for (var i = 0; i < preElements.length; i++) {' +
' var pre = preElements[i];' +
' if (pre.getAttribute("data-diff-type")) {' +
' addClass(pre, "hljs");' +
' }' +
' }' +
'};' +
'function registerTabs() {' +
' var tabBtns = getElementsWithClass("tab-btn");' +
' for (var i = 0; i < tabBtns.length; i++) {' +
' tabBtns[i].onclick = function () {' +
' var activeButtons = getElementsWithClass("tab-btn active");' +
' var activeContents = getElementsWithClass("tab-content active");' +
' for (var j = 0; j < activeButtons.length ; j++) { removeClass(activeButtons[j], "active") }' +
' for (var k = 0; k < activeContents.length; k++) { removeClass(activeContents[k], "active") }' +
' addClass(this, "active");' +
' var targetId = this.getAttribute("data-content-id");' +
' var targetContent = document.getElementById(targetId);' +
' if (targetContent) { addClass(targetContent, "active") }' +
' };' +
' }' +
'};' +
'function initLegacy() {' +
' highlightTag("pre");' +
' registerTabs();' +
'};' +
'setTimeout(initLegacy, 100);';
end;

begin
Result := Format(
'<!DOCTYPE html>' +
Expand All @@ -364,7 +417,15 @@ function TRuleHtmlGenerator.BuildHtmlPage(BodyHtml: string; BodyClass: string):
'</head>' +
'<body class="%s">' +
' <div class="content">%s</div>' +
' <script src="script.js"></script>' +
' <script>' +
' if (Object.defineProperty) {' +
' var script = document.createElement(''script'');' +
' script.src = ''script.js'';' +
' document.body.appendChild(script);' +
' } else {' +
GetLegacyScript +
' }' +
' </script>' +
'</body>' +
'</html>',
[GenerateCss, BodyClass, BodyHtml]);
Expand Down
4 changes: 4 additions & 0 deletions client/source/DelphiLint.IDEContext.pas
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ procedure TToolsApiServices.ApplyTheme(Component: TComponent);

procedure TToolsApiServices.RegisterFormClass(FormClass: TCustomFormClass);
begin
{$IF CompilerVersion < 33.0}
(BorlandIDEServices as IOTAIDEThemingServices250).RegisterFormClass(FormClass);
{$ELSE}
(BorlandIDEServices as IOTAIDEThemingServices).RegisterFormClass(FormClass);
{$ENDIF}
end;

//______________________________________________________________________________________________________________________
Expand Down
2 changes: 1 addition & 1 deletion client/source/DelphiLint.LogViewer.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ object LogViewerForm: TLogViewerForm
Height = 15
Caption = 'HH:MM analysis - SonarDelphi log'
end
object ReportButton: TBitBtn
object ReportButton: TButton
Left = 566
Top = 6
Width = 165
Expand Down
1 change: 0 additions & 1 deletion client/source/DelphiLint.OptionsForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ object LintOptionsForm: TLintOptionsForm
Items.Strings = (
'Standalone'
'Connected (SonarQube)')
ShowFrame = False
TabOrder = 0
OnClick = AnalysisModeGroupClick
end
Expand Down
2 changes: 1 addition & 1 deletion client/source/DelphiLint.OptionsForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ procedure TLintOptionsForm.RefreshTheme;
WindowColor: TColor;
begin
LintContext.IDEServices.ApplyTheme(Self);
WindowColor := StyleServices(Self).GetSystemColor(clWindow);
WindowColor := StyleServices.GetSystemColor(clWindow);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove this trailing whitespace.

ContentPanel.Color := WindowColor;
end;

Expand Down
4 changes: 4 additions & 0 deletions client/source/DelphiLint.Plugin.pas
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ interface
, Vcl.Menus
, Vcl.Forms
, DelphiLint.Handlers
{$IF CompilerVersion < 33.0}
, DelphiLint.ToolFrame.Tokyo
{$ELSE}
, DelphiLint.ToolFrame
{$ENDIF}
, DelphiLint.SettingsFrame
, DelphiLint.OptionsForm
, DelphiLint.Context
Expand Down
7 changes: 4 additions & 3 deletions client/source/DelphiLint.Properties.pas
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,11 @@ constructor TPropertiesFile.Create(Path: string);

destructor TPropertiesFile.Destroy;
var
Field: TPropFieldBase;
I: Integer;
begin
for Field in FFields do begin
FreeAndNil(Field);
for I := 0 to Length(FFields) - 1 do
begin
FreeAndNil(FFields[I]);
end;

inherited;
Expand Down
4 changes: 4 additions & 0 deletions client/source/DelphiLint.Resources.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ interface
, Vcl.Graphics
, Vcl.Imaging.pngimage
, DelphiLint.Data
{$IF CompilerVersion < 33.0}
, DelphiLint.ToolFrame.Tokyo
{$ELSE}
, DelphiLint.ToolFrame
{$ENDIF}
;

type
Expand Down
38 changes: 34 additions & 4 deletions client/source/DelphiLint.Server.pas
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ TLintServerThread = class(TThread)
procedure RefreshServer;
procedure ReleaseServer;
end;
//______________________________________________________________________________________________________________________

{$IF CompilerVersion < 33.0}
function EscapedString(AValue: string): string;
{$ENDIF}

//______________________________________________________________________________________________________________________

Expand Down Expand Up @@ -514,7 +519,7 @@ procedure TLintServer.OnAnalyzeResponse(
begin
Result := TObjectList<TLintIssue>.Create;
for Index := 0 to Json.Count - 1 do begin
Result.Add(TLintIssue.CreateFromJson(Json[Index] as TJSONObject));
Result.Add(TLintIssue.CreateFromJson(Json.Items[Index] as TJSONObject));
end;
end;

Expand All @@ -524,7 +529,7 @@ procedure TLintServer.OnAnalyzeResponse(
begin
SetLength(Result, Json.Count);
for Index := 0 to Json.Count - 1 do begin
Result[Index] := Json[Index].Value;
Result[Index] := Json.Items[Index].Value;
end;
end;

Expand Down Expand Up @@ -607,7 +612,7 @@ procedure TLintServer.OnRuleRetrieveResponse(
Rules: TObjectDictionary<string, TRule>;
begin
if Response.Category <> CRuleRetrieveResult then begin
ErrorMsg := Response.Data.AsType<string>;
ErrorMsg := (Response.Data as TJSONString).Value;
ErrorCat := Response.Category;

Log.Warn('Rule retrieve returned error (%d): %s', [ErrorCat, ErrorMsg]);
Expand Down Expand Up @@ -1009,7 +1014,7 @@ function TLintServerTcpConnection.DoReceiveMessage: TTaggedMessage;

DataBuffer := TBytes(IdDataBuffer);

DataJsonValue := TJSONValue.ParseJSONValue(DataBuffer, 0, Length, True);
DataJsonValue := TJSONObject.ParseJSONValue(DataBuffer, 0, Length, True);
Result := TTaggedMessage.Create(TLintMessage.Create(Category, DataJsonValue), Id);
end;

Expand All @@ -1027,7 +1032,11 @@ procedure TLintServerTcpConnection.DoSendMessage(Msg: TTaggedMessage);
Message := Msg.Extract;

if Assigned(Message.Data) then begin
{$IF CompilerVersion < 33.0}
DataBytes := TEncoding.UTF8.GetBytes(EscapedString(Message.Data.ToString));
{$ELSE}
DataBytes := TEncoding.UTF8.GetBytes(Message.Data.ToString);
{$ENDIF}
Comment on lines +1035 to +1039
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What's the reasoning behind this change?


FTcpClient.IOHandler.Write(Length(DataBytes));
for DataByte in DataBytes do begin
Expand Down Expand Up @@ -1123,4 +1132,25 @@ function TTaggedMessage.Extract: TLintMessage;
FMessage := nil;
end;

//______________________________________________________________________________________________________________________

{$IF CompilerVersion < 33.0}
function EscapedString(AValue: string): string;
begin
if AValue.StartsWith('"') then
AValue := AValue.Substring(1, AValue.Length-2);

// Tratar estes caracteres especiais: \, ", #$8, #$9, #$a, #$c, #$d
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please translate this comment into English.

Result := AValue
.Replace('\', '\\')
.Replace(#$8, '\b')
.Replace(#$9, '\t')
.Replace(#$a, '\n')
.Replace(#$c, '\f')
.Replace(#$d, '\r');

Log.Info('ToString: ' + Result);
end;
{$ENDIF}

end.
6 changes: 3 additions & 3 deletions client/source/DelphiLint.Settings.pas
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,16 @@ procedure TLintSettings.SyncTokenMap;
begin
FTokensMap.Clear;

HostTokenPairs := SplitString(SonarHostTokens, ',');
HostTokenPairs := TArray<string>(SplitString(SonarHostTokens, ','));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of these changes?

for Pair in HostTokenPairs do begin
SplitPair := SplitString(Pair, '=');
SplitPair := TArray<string>(SplitString(Pair, '='));

if Length(SplitPair) <> 2 then begin
Log.Warn('Skipping invalid value ''%s'' in Sonar token mapping', [Pair]);
Continue;
end;

SplitIdent := SplitString(SplitPair[0], '@');
SplitIdent := TArray<string>(SplitString(SplitPair[0], '@'));

if Length(SplitPair) <> 2 then begin
Log.Warn('Skipping invalid value for key ''%s'' in Sonar token mapping', [SplitPair[0]]);
Expand Down
14 changes: 0 additions & 14 deletions client/source/DelphiLint.SettingsFrame.dfm
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are these changes accidental?

Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,12 @@ object LintSettingsFrame: TLintSettingsFrame
Top = 26
Width = 453
Height = 49
DefaultHeaderFont = False
DoubleBuffered = False
HeaderFont.Charset = DEFAULT_CHARSET
HeaderFont.Color = clBtnText
HeaderFont.Height = -1
HeaderFont.Name = 'Segoe UI'
HeaderFont.Style = []
ItemIndex = 0
Items.Strings = (
'Use the default version'
'Use a specific version')
ParentDoubleBuffered = False
ShowFrame = False
TabOrder = 1
OnClick = SonarDelphiVersionRadioGroupClick
end
Expand All @@ -190,19 +183,12 @@ object LintSettingsFrame: TLintSettingsFrame
Top = 130
Width = 221
Height = 49
DefaultHeaderFont = False
DoubleBuffered = False
HeaderFont.Charset = DEFAULT_CHARSET
HeaderFont.Color = clBtnText
HeaderFont.Height = -1
HeaderFont.Name = 'Segoe UI'
HeaderFont.Style = []
ItemIndex = 0
Items.Strings = (
'Use SonarDelphi'#39's default ruleset'
'Use a custom ruleset')
ParentDoubleBuffered = False
ShowFrame = False
TabOrder = 2
OnClick = StandaloneRulesRadioGroupClick
end
Expand Down
4 changes: 2 additions & 2 deletions client/source/DelphiLint.SettingsFrame.pas
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ procedure TLintSettingsFrame.PopulateStandaloneRulesBox;
Exit;
end;

DisabledRules := SplitString(LintContext.Settings.StandaloneDisabledRules, ',');
DisabledRules := TArray<string>(SplitString(LintContext.Settings.StandaloneDisabledRules, ','));

SortedRules := FStandaloneRules.Values.ToArray;
TArray.Sort<TRule>(SortedRules, TComparer<TRule>.Construct(
Expand Down Expand Up @@ -384,7 +384,7 @@ procedure TLintSettingsFrame.RetrieveReleases;
SetLength(Releases, Json.Count);

for Index := 0 to Json.Count - 1 do begin
ReleaseVersion := Json[Index].GetValue<string>('tag_name');
ReleaseVersion := Json.Items[Index].GetValue<string>('tag_name');

if StartsStr('v', ReleaseVersion) and (Length(ReleaseVersion) > 1) then begin
ReleaseVersion := Copy(ReleaseVersion, 2);
Expand Down
Loading
Loading