Find unused classes or dead code in Haxe project - haxe

Somebody know a way to automatically get a list of unused classes in Haxe project?
I not find documentation about that, but the information should be available somewhere. Like a diff after dead code elimination.

You can get a DCE log by compiling with -D dce-debug. (relevant entry in the manual)
For example, compiling a class Hello { static function main() trace("Hello!"); } with haxe --interp -main Hello -D dce-debug yields something like:
...
[DCE] Removed field Type.getClass
[DCE] Removed field Type.getEnum
[DCE] Removed field Type.getSuperClass
[DCE] Removed field Type.getClassName
[DCE] Removed field Type.getEnumName
[DCE] Removed field Type.resolveClass
[DCE] Removed field Type.resolveEnum
[DCE] Removed field Type.createInstance
[DCE] Removed field Type.createEmptyInstance
[DCE] Removed field Type.createEnum
[DCE] Removed field Type.createEnumIndex
[DCE] Removed field Type.getInstanceFields
[DCE] Removed field Type.getClassFields
[DCE] Removed field Type.getEnumConstructs
[DCE] Removed field Type.typeof
[DCE] Removed field Type.enumEq
[DCE] Removed field Type.enumConstructor
[DCE] Removed field Type.enumParameters
[DCE] Removed field Type.enumIndex
[DCE] Removed field Type.allEnums
[DCE] Removed class Type
[DCE] Removed enum ValueType
...

Finally, I mix two solutions to get a full answer.
The first one is a diff between Haxe files in source path and parsed classes in verbose mode compilation.
The seconds one is a diff with dce-debug and files in source path. thx #jonasmalacofilho
You can find my script on gist : https://gist.github.com/aliokan/0a9abded7c079ad0260f651245964db2

Related

Python xml.etree.ElementTree issue, Element.tag is getting me more than just the tag name

I'm having a lot of trouble doing something as simple as just getting the tag of an Element from an XML file. This is the element, with sensitive info removed:
<FIXML xmlns="AAA/AAAAA-5-0-AAA" v="AAA.5.AAAA" xv="111" cv="AAA" s="2013-10-14">
I attempted to get the tag of this element with this simple line of code:
tag1 = root.tag
And for some reason this is not behaving as expected. It is giving me this value:
{AAA/AAAAA-5-0-AAA}FIXML
It's attaching the value of the first attribute to it, as a prefix in curly braces? Why on earth is it doing that? I just want it to return FIXML and nothing else, which according to the documentation here is what I understood it to do. Any ideas?
Python version: 3.7
User mzjn was correct here, I didn't realize that namespaces were returned as well. The way I resolved this was by stripping the namespace off:
# Strip namespace off of root tag
if '}' in tag:
tag = tag.split('}', 1)[1]
This resulted in the intended output by stripping everything after the closing tag. Obviously this assumes there's no } character in the tag or namespace itself.

Adding Metadata Attribute with white-space — Unix shell command

I'm trying to change a metadata attribute on a file, in a Node.js app, the problem is that I need to use white-space in the attribute value. I tried the following (used \ to add the white-space) but it did not work:
In the sample below, the Musical Genre should be Hip Hop.
exec('xattr -w com.apple.metadata:kMDItemMusicalGenre "Hip\ Hop" PATH-TO-FILE')
I also tried removing quotes (") or using template literals to wrap the script, but none of them worked. Would you please help me to find out how to sort this out? Thank you in advance.

HibernateSearch/Lucene searching in index with undersclore

I declared a field where I wanna save values with underscores in it. Therefore I marked the field with the #Field annotation like:
#Field(name = "underscoreField", index = Index.UN_TOKENIZED).
In Luke I can see that the index is created correctly. For instance:
ABC_EF_AB
When I search for "ABC_EF_AB" or "ABC_" I can't find any result. I already tried the Standard and the Keyword Analyzer.
Thanks
Try the WhitespaceAnalyzer. It uses a WhitespaceTokenizer that breaks at whitespace, so it should allow underscores.

IS warning about string ID "IDS_ERROR_27555" not being found in string table

I have an Installshield2010 project that has had this warning since before my employment
ISDEV : warning -3028: The string ID "IDS_ERROR_27555" was not found in the string table. It is referenced in the table:"Error" in column:"Message".
Looking in the svn history, this row was added to Error table a few years ago - alongside a seemingly unrelated change
<row><td>27555</td><td>##IDS_ERROR_27555##</td></row>
However as the error indicates, there is no corresponding entry in the ISString table.
I'm curious how it got added. The IDS_ERROR strings look like canned strings, it seems really unlikely the person who added this to my ism did so manually.
Of course Flexera's forums are a ghost town. I did find an ism that has that string defined as
<row><td>IDS_ERROR_27555</td><td>1033</td><td>Error attempting to apply permissions to object '[2]'. System error: [3] ([4])</td><td>0</td><td/><td>1394414478</td></row>
Do any of your ism's have IDS_ERROR_27555 defined or referenced? Am very sure I can delete the string and be no worse for wear... but it bugs me to not know what happened.
I don't remember in which version we added these strings, but you can get them by importing the strings file for your language (1033.txt for English) under the Languages folder. Upgrading across versions of InstallShield should have added this string. You can add them yourself by importing the strings file in the String Editor view. Of course if you've modified other strings, you'll want to ensure that you keep your preferred version.

Invalid Parameter Name

I am having a problem with saving of data because of an incorrectly generated parameter name.
The table has a field "E-mail", and when the class wrapper is generated, the InsertCmd uses "#E-mail" as one of the parameters. In SQL Server, this is illegal and generated an exception.
I have hunted all over SubSonic for a way to modify the parameter name to simply "#Email" but the ParameterName property is read only.
I am using SubSonic 2.2 and don't have the source for it to make an internal modification.
Any ideas?
TIA
I got a mate of mine that uses SVN to pull the source code, and as expected, found a bug in the SS source.
When the column name is set in the class wrapper, the setter for the ColumnName property sets the ParamaterName property for you correctly using
"parameterName = Utility.PrefixParameter(Utility.StripNonAlphaNumeric(columnName), Table.Provider);". This removes any illegal characters like the hyphen in my E-mail column.
BUT... The property ParameterName is NOT used when the SQL commands are created. Here is the code in SQLDataProvider.GetInsertSQL, line 1462.
pars.Append(Utility.PrefixParameter( colName, this));
I changed this to
pars.Append(col.ParameterName);
and the problem is now sorted.
Thanks to you that came up with possible solutions.
You can modify the templates if you can't change the column name. See this blog post for details of how:
http://johnnycoder.com/blog/2008/06/09/custom-templates-with-subsonic/

Resources