How to disable specific closure DiagnosticType, rather than whole DiagnosticGroup? - google-closure-compiler

I'm trying to use Closure as a sort of linter on steriods in my code. I want all warning on, except for this particular DiagnosticType (POSSIBLE_INEXISTENT_PROPERTY), which causes a ton of noise on my externs. Is there any way to disable that particular diagnostic, without disabling the whole missingProperties group?

No - not by default. You would need to make a custom build of the compiler.

Related

Wordpress Plugin - Why is WP altering "[i]" (and others)?

First off, I'll say that I do have a lot of experience programming, but I'm incredibly inexperienced with WordPress. I'm guessing there's a correct WordPress way to do what I want and maybe I'm not using the right method, which is why I'm having trouble.
In a nutshell, my plugin reaches out to my company's server via CURL and retrieves a bunch of code (html, css, and javascript) to put on the page. It's been working fine for many years, but recently our customers have started to complain about broken functionality. Turns out it's javascript errors.
Digging deeper, we discovered that wordpress (or something) is replacing seemingly arbitrary bracketed text with seemingly arbitrary content. I see no rhyme or reason to this. For example, within the following javascript that my plugin pulled in from our server, it replaced the [i] with some random html.
Original code:
var optname = order_other_options[oname][i][optid];
After wordpress munged it:
var optname = order_other_options[oname]<div class='iconfa' style='text-align: left;'><iclass=''></i></div>[optid];
It replaced [i] with <div class='iconfa' style='text-align: left;'><iclass=''></i></div>
What's weird is that there are probably a dozen instances of [i] throughout the same javascript function, but it was only replacing four instance. ???
For another customer, it's replacing an instance of [n] with [n], yet it doesn't try to replace the brackets with &# codes in other instances within that js function.
As a temporary solution for the first customer complaint, we changed the code on our server to be [x] instead of [i] and that fixed the problem. But now I see that it seems somewhat indiscriminate about what it replaces.
I could probably write something that prepends js array variables with ersVar_ or something, something like "[ersVar_x]", but that's such a hack, I'd much rather get to the bottom of the problem.
The way my plugin works is by using add_filter(), and our customers utilize the plugin by adding a merge field [store: <account ID>], the plugin then just str-replaces that merge field with our content.
Maybe add_filter() isn't the best option? Is there another function I can use instead that would guarantee that nothing would ever attempt to modify the content my plugin generates?
And if you do recognize what's happening here, I'd be really curious to know, since none of the developers at my office could find any discernible pattern about when and why it replaces things.
Any insights are appreciated.
The issue here was the hook and the priority used on that hook.
To understand things better, please see the below explanation of the parameters in add_filter
Hook: This is the event that triggers the callback function. In Adam's case the hook was the_content.
Callback: The callback function to be triggered whenever apply_filters is called on the respective hook.
Priority: This helps you specify on how early or how late to trigger the callback function. Defaults to 10. The lower the number, the earlier the callback is called for execution. That turned out to be a problem for Adam as by using the default priority of 10, he was allowing other functions to be called after his has finished execution. It was solved by changing the priority to 999.
Parameter Count: This is the number of parameters accepted by the callback function. Defaults to 1.

Frama-C's extensible printer and projects

I am trying to make changes to the behavior of a function and print the results to a file. The ViewCfg plug-in described in the Plug-in Development Guide does something similar, but I am trying to avoid having to use Ast.get, which ViewCfg uses. I am thinking of extending Printer.extensible_printer which, according to the Frama-C API Documentation, is something I can do if I want to obtain a custom pretty-printer.
However, if I extend the pretty-printer as described in the API docs, unless I'm doing something wrong, I notice that the changes I make take place regardless of which project is set as the current project. I'm using File.create_project_from_visitor to create a new project and Project.set_current to set the new project as the current project before I use the custom pretty-printer.
Is it true that any change made by a class that extends Printer.extensible_printer applies to all projects? I happen to be using frama-c-Aluminium-20160502, which I know is not the latest version.
EDIT: Sorry, I should have made this clearer in the beginning, but I'm not actually making changes to the behavior of a function. I'm reading in the behavior of a function, then based on that, I'm trying to generate as output valid C code that's meant to be read as input by another program.
Regarding AST.get, the only reason I was avoiding it was that it sounds like it gets the entire AST, while I'm only interested in part of it, i.e. behaviors. But if I'm just making things harder for myself by avoiding it, then I'll go ahead and use it.

Advanced compilation level - list of removed methods

I've started to use closure compiler and still hittin lot's of obstacles:)
I'm looking for the option that will output the list of removed methods/properties whatnot during the optimisation done by compiler - this would help me a lot when debugging the code.
There is no default option that lists removed symbols.
This should be possible by using a tool to highlight all of the lines that have mappings in a generated source map. Any line that has no mapping was dropped as dead code.
However I have not stumbled across a tool that would do this. It would be highly useful though and not specific to Closure-compiler.

Customizing queryCatalog script in Plone or using reversed chronological order by default

I have been asked to help in tweaking an Intranet done with Plone 4.0.5; one of the requirements is to always (by default) use the reversed chronological order in folder's listings.
I haven't touch Plone since it was at version 2.5; so lots have changed.
Is there any simple parameter/configuration to accomplish this?
Failing that. I have tracked the fetching of the showed items to queryCatalog script inside portal_skins/plone_scripts.
I have customized this script TTW. Later I plan to customize this by means of whatever you recommend (an adapter?, a ZCML? I have yet to study that stuff). What are the best practices these days?
If I have set the 'sort_on' and 'sort_order' keys by hand everything seems to behave as I'd want. But if I use the setdefault method of dicts, then nothing happens, so it seems that an order has been requested.
How can I log inside a script customized TTW?
instead of patching the catalog (which might change sort order in navigation or other places where you don't want/need it) you could
customize the folder-views you're using (eg folder_summary_view)
this might help: http://keeshink.blogspot.co.at/2009/06/how-to-change-plones-default-folder.html
use collections to display items contained in the folder (only a good idea if you need the reverse order just in some folders)
or use one of these addons http://plone.org/products/collective.sortmyfolder
or http://pypi.python.org/pypi/wildcard.foldercontents
For logging:
context.plone_log('My script', 'My message')
You seem to be on the right track otherwise.

GDB in Qt not refreshing values correctly

I am trying to use the debugger in a thread but the values of the watched variables dont get updated in them unless i remove the break point, make it run for a while then put break point back. They also get refreshed if a messageBox appears. Why is this?
There could be a number of reasons. My best guess is that you're putting break points in decompiled code, where as the compiled code may not occur in that order (as the compiler will move things around). You should consider setting your compiler to a lower level of optimization.

Resources