Jump to content

JonRobertson

Members
  • Content Count

    171
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by JonRobertson


  1. 25 minutes ago, Brandon Staggs said:

    Agreed that the compiler should let us know if we don't set Result in a function regardless of the result type.

    Agreed.

     

    I still think the code demonstrated in the report (and the example posted by Der schöne Günther) is unexpected behavior. 

    		objectAsString := 'Hello World';
    		objectAsString := TJson.Format(objectAsJson);
     
    		WriteLn(objectAsString); // << It is "Hello World{}" (not including linebreaks)

    I would not expect 150 to be written to the console for this code:

    function GetAmount: Integer;
    begin
      Result := 50;
    end;
    
    begin
      var i: Integer := 100;
      i := GetAmount;
      writeln(i);
    end.

    The compiler even hints that the initial value is never used.

    [dcc32 Hint] H2077 Value assigned to 'i' never used

     


  2. When I started using Delphi 11.x, I was frustrated by frequent IDE lockups and exceptions. After talking to Embarcadero, I selectively uninstalled each component library and expert to try and identify if third-party code was causing those issues.

     

    The issues that I was experiencing disappeared once I uninstalled the Parnassus debugger and bookmarks experts. Since then, Delphi 11.3 has been extremely stable for me.

     

    Jon


  3. I copy components from the designer to clipboard quite frequently and I do not recall that issue ever occurring. The most recent versions that I have used are 11.2, 11.3, and 12.0 (without Patch 1).

     

    I would also check Task Manager to see what else is running in the background. There could be another application that is monitoring the clipboard and interfering with BDS.exe when you try to copy components.


  4. 8 hours ago, Der schöne Günther said:

    it could probably have been something like this

    I do believe our "issue" was with a String return value rather than a local variable. It amazes me that after using Delphi for 28 years, there are still things, even basic features, that I haven't learned.

     

    Thank you for your post, which led to a search, then to so initialise-string-function-result, and then to this in the docs:

    • For a string, dynamic array, method pointer, or variant result, the effects are the same as if the function result were declared as an additional var parameter following the declared parameters. In other words, the caller passes an additional 32-bit pointer that points to a variable in which to return the function result.

  5. 3 minutes ago, Attila Kovacs said:

    Wow, from now on, you can open the same file multiple times. That's going to be interesting.

    The IDE only opens the file once, regardless of how many tabs are "editing the same unit".

     

    Designer and Code

    Note: Remember, there is only one file (module or file buffer in internal terms), but multiple editor views over that file, so a change you make in one editor is always reflected in every other editor for the same file. A change made in one editor is not ‘copied’ or ‘duplicated’ or anything else: there is only one file and one content for that file, even if you have multiple editors viewing/editing that file.
    Another way of saying this is that when you edit a file in one editor, that change is in the file itself, not the editor. By definition, that means that change is always present in the other editors also showing the same file.

  6. 41 minutes ago, Lars Fosdal said:

    Variable not initialized - I set that one to raise a compile error - because those WILL bite you.

    I do as well. I even initialize strings and arrays. Although I have not seen this occur in years, I had an issue, around 15 years ago, in a Delphi 6 project where a local string variable was not initialized to empty string.


  7. 2 hours ago, David Heffernan said:

    I always debug 32 bit if at all possible.

    I do as well.

     

    2 hours ago, David Heffernan said:

    But sometimes you have a scenario where that's not possible.

    Such as weird UI issues that do not occur in 32-bit but do occur in 64-bit, which I've encountered more than once. :classic_wacko:


  8. Downloaded and installed. This is very helpful, even without adding custom visualizers.

     

    I looked on sf for a way to add an "issue" and checked the blog. I suppose you want all feedback to be on this post.

     

    In Tools Options, after clicking "Add Defaults", I then deleted each of the items that were added. Except the Delete button does nothing when there is a single item in the list.

     

    image.thumb.png.52555e6fc29d0c0640ab754e70be2028.png

    • Like 1

  9. For anyone that has DelphiLint installed, I just filed ticket Issue 20 because BDS.exe was racing one logical CPU when the IDE was otherwise idle and no projects were loaded. Once I removed the Delphi Lint package, BDS.exe CPU usage dropped to 0%.

     

    Delphi 11.3 (28.0.48361.3236)

    DelphiLintClient-1.0.1-Alexandria.bpl

    delphilint-server-1.0.1.jar

    plugins\DEFAULT-sonar-delphi-1.3.0.jar


  10. 7 minutes ago, Elliot Hillary said:

    Sorry to hear you had issues starting up SonarQube - is it possible that the root cause is the same as #8? This part of the SonarQube documentation could be helpful.

    It could be. I followed the instructions and was in a console window when starting the service. I don't remember anything written to the console window that would have indicated the problem was related to that issue.

     

    Now that DelphiLint standalone is working, next week I may installing SonarQube again and try to get a "connected" configuration working. I still need to install our certificate in the JVM and verify that DelphiLint is able to download SonarDelphi.

     

    13 minutes ago, Elliot Hillary said:

    By default, DelphiLint and SonarDelphi follow Delphi's Object Pascal Style Guide, so this is where the naming convention rules get their standard opinions from.

    My opinion is that naming convention is not a risk factor, which is the benefit of static analysis. Perhaps there is a risk that I am not aware of. I could see the benefit of those rules being available, just turned off by default. Another example is the default name of a "break" in a menu (main menu or popup menu). The default is "N1" for the first break, "N2" for the second, etc. Sonar suggests that I give those menu items a more meaningful name. As an experienced Delphi developer, naming it "miBreak1" is no more meaningful than "N1", because I know what they are and I don't need to reference them in code.


  11. On 3/19/2024 at 5:07 AM, Elliot Hillary said:

    If there's a lot of interest in customising the rules in standalone mode, that's certainly something that could make its way into a future release.

     

    I definitely would appreciate customizing rules in standalone mode. I attempted installing SonarQube and going the "connected mode" route. However, I had difficulty getting the SonarQube service started and I am not a Java guy.

     

    Some of the rules are more annoying than helpful. I have no idea what "naming conventions" DelphiLint is expecting. One convention seems to be that unit names must be PascalCase. Particularly for legacy projects, there is no benefit. Yes, a consistent naming convention is very helpful. Does anyone care that all of our form units follow formMain.pas rather than FormMain.pas?

     

    I almost want to create an issue for the rule "split this 128 characters long line (which is greater than 120 authorized)". Authorized by who, or what? Certainly not by me, my employer, or anything that I've configured in Delphi.

     

    Others are personal preferences. "Delphi style guides" may advise against using () when calling a routine without arguments. But I prefer to have them. They do no harm and I think they improve code read-ability.

     

    Those are just a couple examples where the ability to customize the rules, even in standalone mode, would be appreciated.

    • Like 1

  12. I've never heard of the Delphi IDE "using" an external editor. The integration between the editor and the rest of the IDE (designer, object inspector, tool palette, etc) would likely need a heavy refactor or rewrite. But as  @Lars Fosdal mentioned, you can edit Pascal source in any text editor. The project below is a Delphi plug-in that adds a command to the Tools menu to open the current unit in Visual Code. With a little configuration, you could switch between Delphi and Visual Code at will, taking advantage of features in Visual Code such as Copilot.

     

    EditInVsCodeDelphiPlugin

    • Thanks 1

  13. A project that I inherited has warning "W1047 Unsafe code" enabled. I normally do not enable that warning. There is a scenario that I don't understand, even after some online searches.

    [dcc32 Warning] W1047 Unsafe code 'String index to var param'

    From a couple posts that I read, it seems this specific unsafe warning is related to multiple platform support and zero based strings.

     

    It occurs in this (totally useless) code segment:

    function Test(const aStr: String): String;
    begin
      SetLength(Result, Length(aStr));
      var Count := 0;
      for var i := 1 to Length(aStr) do begin
          Inc(Count);
          Result[Count] := aStr[i];
      end;
    end;

    on Result[Count] := aStr;

     

    The wording of the warning confuses me. There is an index to a string, but not what I consider a 'string index'. Does the [] operator for String receive the index as a var param?


  14. 1 hour ago, VoSs2o0o said:

    I cannot use this Tool: When i press "analyze" i get the error

    I suggest creating an Issue here. And there is no reason for an option to be added. The plug-in should determine the correct paths and Delphi version without needing you to configure it.


  15. 9 minutes ago, Elliot Hillary said:

    if you choose to manually download the jar and place it in %APPDATA%\DelphiLint\plugins, it should be named "DEFAULT-sonar-delphi-plugin-1.3.0.jar"

    Thanks for the extra info. Downloaded and renamed. The first unit that I tried to analyze gave this error:

    DelphiLint encountered a problem during analysis.
    
    An error was raised (java.lang.OutOfMemoryError: Java heap space ).

    That unit has 464 lines of code. The entire project has 12,533 lines of code, not counting Delphi RTL, VCL, and third-party components. So this isn't a large project by any means.

     

    This laptop has 32GB of physical memory and 13.5 GB was available at the time of the analysis.


  16. On 3/16/2024 at 3:58 PM, aegger said:

    repoPP : PPgit_repository;

    Your original declaration declared a pointer, but never assigned it to anything. Since it is a local variable on the stack, it contained a garbage/random value rather than a pointer to actual data.

     

    On 3/16/2024 at 9:02 PM, Darian Miller said:

     "repoPP:PGit_repository" and call    "git_repository_init(@repoPP..."

    Darian's suggestion changed your declaration to an instance of data. Using @repoPP then passed the memory address (pointer) of the data to the DLL. See The @ Operator


  17. 50 minutes ago, JonRobertson said:

    I am about to download SonarDelphi manually

    I am curious what the "standalone" version would download from GitHub. Following the link to install SonarDelphi, you need to install SonarQube, then SonarScanner, then install the SonarDelphi plug-in in SonarQube.

     

    I installed SonarQube and configured a database via the install instructions. But the SonarQube service refuses to start.

×