Supress specific warnings/errors - google-closure-compiler

1. Summary
I couldn’t find, how I can get all warnings for all files except specific warnings (not suppression tags).
In my case, I can’t suppress WARNING - [JSC_VAR] Using var (prefer const or let).
2. MCVE
2.1. Data
KiraVar.js:
var KiraVariable = 4147;
CLI command:
google-closure-compiler --js KiraVar.js --language_out ECMASCRIPT_NEXT --warning_level VERBOSE --jscomp_warning *
2.2. Behavior
2.2.1. Expected
No warnings.
2.2.2. Current
KiraVar.js:1:0: WARNING - [JSC_VAR] Using `var` (prefer `const` or `let`).
1| var KiraVariable = 4147;
^^^^^^^^^^^^^^^^^^^^^^^^
0 error(s), 1 warning(s), 100.0% typed
'use strict';var KiraVariable=4147;
3. Reason for suppression
I use CoffeeScript, that not support let and const.
the official CoffeeScript documentation — Unsupported ECMAScript features: let and const;
the official CoffeeScript issue tracker — Allow const keyword.
4. Not helped
I couldn’t find any tool, that can automatically correctly replace var to const or let in JavaScript files. eslint --fix with no-var option doesn’t do it.
I tried --jscomp_off option with values from ParserConfig.java and DiagnosticGroups.java files.
I couldn’t find how I can solve my problem in Google, Stack Overflow and closure-compiler GitHub repository.
5. Don’t offer
Please don’t tell me that I shouldn’t be using CoffeeScript.
I don’t need suppress warnings in specific files. I use var in many files; it would be nice suppress this warning for all files one time. For the same reason, please don’t suggest that I add annotations every time I use var.
--jscomp_off lintChecks works for me, but it will disable 40 errors. I need solely suppress [JSC_VAR], not all of these 40 errors of the supression tag.

The compiler doesn't allow for the suppression of individual lint warnings. If you are willing to create a custom build of the compiler, you can:
added a suppression group
or
remove the check
Removing the check is likely easier to merge with future versions.

Related

GlideApp symbol not found in Android Studio 4.1

I have been using Glide 4.11.0 and Realm 6.0.2 for some time now, and recently upgraded Android Studio 4.0.x to 4.1. All has been going fine. Today I ran the lint checker, and started doing some "clean up", nothing out of the ordinary (it would seem). One of the things I did a lot of was to replace switch statements that were testing against R.id. with if-else statements per the lint warning about what's gonna happen in Gradle 5.0.
When I did this, I did use a number of int variables I named 'id' that were to replace the value to compare - i.e. instead of a switch statement that would be:
switch (menuOpt.getId()) {
case R.id.xxx:
...
}
I would do:
int id = menuOpt.getId();
if ( id == R.id.XXX) {
} else if....
per the new guidelines.
Suddenly, on a full build AS complains that it no longer recognizes GlideApp, and I am also getting a very weird message about Realm not being able to process correctly:
C:\BLD\AndroidStudioProjects\InTouch\app\src\main\java\com\reddragon\intouch\ui\MediaPlayerActivity.java:61: error: cannot find symbol
import com.reddragon.intouch.utils.GlideApp;
^
symbol: class GlideApp
location: package com.reddragon.intouch.utils
C:\BLD\AndroidStudioProjects\InTouch\app\src\main\java\com\reddragon\intouch\ui\MediaDialogActivity.java:92: error: cannot find symbol
import com.reddragon.intouch.utils.GlideApp;
^
symbol: class GlideApp
location: package com.reddragon.intouch.utils
C:\BLD\AndroidStudioProjects\InTouch\app\src\main\java\com\reddragon\intouch\ui\MediaListActivity.java:48: error: cannot find symbol
import com.reddragon.intouch.utils.GlideApp;
^
symbol: class GlideApp
location: package com.reddragon.intouch.utils
Note: Version 10.0.0 of Realm is now available: https://static.realm.io/downloads/java/latest
Note: Processing class Album
error: Class "Album" contains illegal final field "id".
Note: [1] Wrote GeneratedAppGlideModule with: []
Class "Album" contains illegal final field "id".
4 errors
I have had the field 'id' in my Album class for about 2 years with no issues!
No manner of rebuild, invalidating cache and restarting, syncing gradle files or "reload all from disk" seems to help.
Actually, if I invalidate and restart, I don't get the red squiggle in the offending classes that are referencing GlideApp, but as soon as I start to run the app and it goes through a build process it errors out.
I Googled a bit and found one post where there seemed to be some conflict between Realm and Glide (RequestOptions), but the strange thing to me is why would this suddenly start occurring?
I have validated that the GlideAppjava class is in fact getting built - I am using the debug build variant, and I can see in the file system GlideApp.java that is in the ap_generated_sources/debug directory in the proper package where I have my class that extends AppGlideModule with the #GlideModule annotation.
So GlideApp is getting generated. It just isn't getting recognized.
One of the other new things is that I've recently created a Dynamic Feature module. This module does depend on a class that is in the base module (where GlideApp is referenced). Not sure if this is relevant (I had many, many successful builds before I started doing lint clean-up).
So frustrating! Any help appreciated.
It turns out that the answer was staring right at me, although somewhat hidden: part of the lint check that I did was accept some suggestions about making variables 'final' - including those that are used in Realm classes to define Realm objects. Realm doesn't like that - above build error output includes as a last line the statement 'Class "Album" contains illegal final field "id".'
"Album" extends RealmObject, and the "auto accept" of the lint's suggestion to make some of the fields final was the culprit.
I think this issue with Realm caused a ripple effect somehow with the other annotation processing - when I went back to all the RealmObject classes and removed the "final" declaration, build now completes smoothly.

NativeScript Playground: moment.js npm package included but error requiring moment

I just started experimenting with Nativescript and am using the Playground to test things and see how it works.
What I wanted to do: add the moment.js module for formatting date/time
What I tried:
1. added the moment package. This appears to have worked because Playground now shows the moment folder along with files (package.json, ender.js, moment.js, etc) and subfolders.
2. In my code I used this snippet to require "moment"
var Moment = require("moment");
This failed though because I get an error of
Error: Could not find module 'moment'. Computed path '/var/mobile/Containers/Data/Application/xxxx/Documents/Playground/LiveSync/app/tns_modules/moment'
Any suggestions on what I need to change to get it to find 'moment'? I checked in package.json and it has the name as "moment".
The default require statement will search for the module form the tns_modules directory that was packed with the app during build time. So with Playground you could use relative path.
For example, if you want to use it on app.js which is in the root level,
var Moment = require('./moment');

sqlite3_key missing from header in iOS 11 framework [duplicate]

I am working on SQLite File Encryption. I have added sqlCipher & crypto frameworks successfully in my project.
Now when I try to compile my application on this line
int rc = sqlite3_key(database, [key UTF8String], strlen([key UTF8String]));
it says Implicit declaration of function 'sqlite3_key'
So above line "implicit declaration" sounds to me like function is defined but not declared. But where I have to declared ?
While searching over Internet, under this article, it says like SQLite Encryption Extension(SEE) is not available publically. I have to purchase it of cost around $2000.
SEE -> http://www.hwaci.com/sw/sqlite/see.html
So this is the only reason I am getting Implicit declaration & False response while sqlite encryption process ?
If you are using SQLCipher, you need to define SQLITE_HAS_CODEC in your application's C Flags. Thats all.
Yes, that is the reason you are getting that compiler warning. The function sqlite3_key() is not defined in the version of libsqlite3 included with iOS. Adding in a function declaration isn't going to help-- it would fix that compiler warning, but it would just mean you'll get a linker error since the function isn't defined anywhere.
If you purchased SEE you could probably build your own copy of SQLite, embed it in your app, and just not use the system's libsqlite3. That this would mean you'd have to say "yes" when the app store submission process asks if your app includes encryption, meaning extra paperwork and time before you could submit the app. I'm not certain whether there's any clear indication of whether Apple would accept it even then-- probably they would, but they've been known to surprise people.

How can I use reflection with Java 9 on the Java internals?

We use this type of Reflection only in our test framework and not in production. We want add some jar files to the app classloader depending of our test code. Is there any workaround for it? How can we get access to not exported classes?
java.lang.reflect.InaccessibleObjectException: Unable to make member of class jdk.internal.loader.ClassLoaders$AppClassLoader accessible: module java.base does not export jdk.internal.loader to unnamed module #9f73a2
at jdk.internal.reflect.Reflection.throwInaccessibleObjectException(Reflection.java:414)
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:174)
at java.lang.reflect.Method.checkCanSetAccessible(Method.java:191)
at java.lang.reflect.Method.setAccessible(Method.java:185)
Accessing module-internal classes can not be done from code. This is on purpose. But there is a workaround from the command line - a non-standardized option on java that does what you want:
--add-exports <module>/<package>=<target-module>(,<target-module>)*
updates <module> to export <package> to <target-module>,
regardless of module declaration.
<target-module> can be ALL-UNNAMED to export to all
unnamed modules.
Note
Java 9 is a moving target and the exact syntax has been changed a couple of times - as was this answer. This means (a) some of the comments below may seem outdated and (b) the flag might not work exactly like that. Please leave a comment and it will get fixed.

Use SQLite with biicode

So far I have been able to succesfully use boost, cereal and gtest using biicode but I am having troubles with sqlite. I am trying to use it doing the following:
#include <sqlite3.h>
So I edited my biicode.conf to include those lines, including the alising for the header:
[requirements]
sqlite/sqlite:9
[includes]
sqlite.h: sqlite/sqlite/sqlite3/sqlite3.h
But when I try to call bii cpp:build it does the following
WARN: Removing unused reference to "sqlite/sqlite: 9" from myuser/test "requirements"
Then I ended up with the expected:
database_impl.cpp:(.text+0x516): undefined reference to `sqlite3_exec'
Surprisingly, the compilation succedd even though sqlite3.h is obviously not included but that's maybe because the call to sqlite is from a template function.
I have looked at the example but CMakeList.txt does not seem to add any additional includes directories. For example for boost I had to add:
SET(Boost_USE_STATIC_LIBS OFF)
bii_find_boost(COMPONENTS chrono system filesystem log thread REQUIRED)
target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${Boost_INCLUDE_DIRS})
target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES})
But the two examples I found here and here don't seem to add anything to the includes directories, not even a link folder. I suppose sqlite has to be compiled with your sources so how do I make biicode add those files to my projects automatically ?
There're several problems. You just wrote in [includes] section sqlite.h instead of sqlite3.h and you should only write the prefix, sqlite/sqlite/sqlite3, later instead of the full dependency name.
Then, you can solve it so:
[requirements]
sqlite/sqlite: 9
[includes]
sqlite3.h: sqlite/sqlite/sqlite3
Or, you could try the SQLite version uploaded into fenix user:
[requirements]
fenix/sqlite: 0
[includes]
sqlite3.h: fenix/sqlite
Don't worry about a "WARN" message that says biicode is ignoring sqlite3.c file because it's harcoded into the block CMakeLists.txt to catch this file ;)
Note: you should write your external #includes's with double quotes instead of <>, because the last ones are referred to system headers and biicode could be using some system deps and you don't realize it.

Resources