How to ignore a specific warning in PyDev? - eclipse

How do I ignore a specific warning in Eclipse?
I am doing ZetCode's PyQt4 tutorial LPTHW style (yes, I'm using PyDev), and adding helpful comments so I can use it as a reference. Eclipse is bugging me about an unused variable. (It is being used, because the initialization function automatically runs the code. Just to be clear.)
I don't want to turn it off for the whole file, because that is actually handy in most situations. I just want to ignore that warning.

For suppressing warnings on a specific line, your only option is to add a comment such as ##UnusedVariable to the line:
def foo():
x = 5 # #UnusedVariable
return 10
To suppress a different type of warning, see the list of suppression string constants in the PyDev source code:
public static final String MSG_TO_IGNORE_TYPE_UNUSED_IMPORT = "#UnusedImport";
public static final String MSG_TO_IGNORE_TYPE_UNUSED_WILD_IMPORT = "#UnusedWildImport";
public static final String MSG_TO_IGNORE_TYPE_UNUSED_VARIABLE = "#UnusedVariable";
public static final String MSG_TO_IGNORE_TYPE_UNDEFINED_VARIABLE = "#UndefinedVariable";
public static final String MSG_TO_IGNORE_TYPE_DUPLICATED_SIGNATURE = "#DuplicatedSignature";
public static final String MSG_TO_IGNORE_TYPE_REIMPORT = "#Reimport";
public static final String MSG_TO_IGNORE_TYPE_UNRESOLVED_IMPORT = "#UnresolvedImport";
public static final String MSG_TO_IGNORE_TYPE_NO_SELF = "#NoSelf";
public static final String MSG_TO_IGNORE_TYPE_UNDEFINED_IMPORT_VARIABLE = "#UndefinedVariable";
public static final String MSG_TO_IGNORE_TYPE_UNUSED_PARAMETER = "#UnusedVariable";
public static final String MSG_TO_IGNORE_TYPE_NO_EFFECT_STMT = "#NoEffect";
public static final String MSG_TO_IGNORE_TYPE_INDENTATION_PROBLEM = "#IndentOk";
public static final String MSG_TO_IGNORE_TYPE_ASSIGNMENT_TO_BUILT_IN_SYMBOL = "#ReservedAssignment";
public static final String MSG_TO_IGNORE_TYPE_PEP8 = "#IgnorePep8";
public static final String MSG_TO_IGNORE_TYPE_ARGUMENTS_MISATCH = "#ArgumentMismatch";
For example:
def get_answer(format='string'): # #ReservedAssignment
answer = 42.0
if format == 'string':
return str(answer)
elif format == 'int':
return int(answer)
else:
return answer

Related

What are the "built-in" filter options for ag-grid?

I see a reference to a built-in filter for "empty" in the doc below. Where can I find documentation for all built-in filter options?
https://www.ag-grid.com/javascript-grid-filtering/#adding-custom-filter-options
I couldn't find it in the documentation either.
However, you can look at the definition of the BaseFilter of the ag-grid here on the GitHub and get all the built-in filters.
export abstract class BaseFilter<T, P extends IFilterParams, M> extends Component implements IFilterComp {
public static EMPTY = 'empty';
public static EQUALS = 'equals';
public static NOT_EQUAL = 'notEqual';
public static LESS_THAN = 'lessThan';
public static LESS_THAN_OR_EQUAL = 'lessThanOrEqual';
public static GREATER_THAN = 'greaterThan';
public static GREATER_THAN_OR_EQUAL = 'greaterThanOrEqual';
public static IN_RANGE = 'inRange';
public static CONTAINS = 'contains'; //1;
public static NOT_CONTAINS = 'notContains'; //1;
public static STARTS_WITH = 'startsWith'; //4;
public static ENDS_WITH = 'endsWith'; //5;
// .....
}

Eclipse code formatter customization

I've recently configured my Eclipse Formatter and I'm pretty happy with how it works, except for one thing. I'd like to set it up so my member variables are sorted into 3 distinct group with a blank line between each of the groups. I want the first group to be static final variables (constants), the second to be regular static variables, and in the third I want all the non-static variables (or again split final and non-final ones, I don't mind either way).
For example, I'd like my class to look like this:
public class Foo {
public static final String PATH_TO_BAR = "C:/Drunken/Clam/Bar";
public static final int N_BARS = 42;
public static BufferedWriter logger;
public int foobar;
public String barfoo;
private int lengthOfBarFoo;
...
}
but right now it formats it as
public class Foo {
public static final String PATH_TO_BAR = "C:/Drunken/Clam/Bar";
public static BufferedWriter logger;
private int lengthOfBarFoo;
public String barfoo;
public static final int N_BARS = 42;
public int foobar;
...
}
Is this possible to set up somehow?
Eclipse save actions might come handy here, however not to such of a detail you've been asking for.
i think you can do that via below :
in eclipse you can sort "Members Sort Order" preference:
"Window -> Preferences -> Java -> Appearance -> Members Sort Order"
you can up and down the choice according to your need.
if you have any query or doubt, comment below.

Is there something wrong with my eclipse calculator?

public class TaxReturn {
private double rate1= 0.10;
private double rate2=0.25;
private double single_limit = 32000;
private double married_limit = 64000;
private double income;
private int status;
public static int married=2;
public static int single=1;
public TaxReturn(double inc, int stat){
double income = inc;
int status=stat;
}
public double getTaxi(){
double tax1=0;
double tax2=0;
if(status==single){
if(income<=single_limit)
tax1=rate1*income;
else{
tax1=rate1*single_limit;
tax2=rate2*(income-single_limit);
}
}
else{
if(income<=married_limit)
tax1=rate1*income;
else
tax1=rate1*married_limit;
tax2=rate2*(income-married_limit);
}
return tax1+tax2;
}
}
import java.util.Scanner;
public class TaxCalculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("eneter income; avoid commas");
double income = sc.nextDouble();
System.out.println("are you married; type Y or N");
String status=sc.next();
int statuss;
if (status.equalsIgnoreCase("y"))
statuss=TaxReturn.married;
else
statuss=TaxReturn.single;
TaxReturn tr = new TaxReturn(income, statuss);
System.out.println("your tax is: " + tr.getTaxi());
}
}
I keep getting-16000 for the answer.I dont know if my code is wrong or something wrong with the software. This code was copied from the book. Iva had this problem with other codes too. Any help would be appreciated. Thanks
Your constructor is not correct.
Rewrite it as follow
public TaxReturn(double inc, int stat){
income = inc;
status = stat;
}
By declaring type on income and status variables, you made them local to the constructor.

How to implement LeafValueEditor<Address>

I am trying to understand how to correctly implement a LeafValueEditor for a non immutable object. Which of the two way is correct, or should something else be used?
public class Address {
public String line1;
public String city;
public String zip;
}
Option 1:
public class AddressEditor implements LeafValueEditor<Address>
{
private String line1;
private String city;
private String zip;
private Address address;
public void setValue(Address value)
{
this.line1 = value.line1;
this.city = value.city;
this.zip = value.zip;
this.address = value;
}
public Address getValue()
{
this.address.line1 = this.line1;
this.address.city = this.city;
this.address.zip = this.zip;
return this.address;
}
}
Option 2:
public class AddressEditor implements LeafValueEditor<Address>
{
private String line1;
private String city;
private String zip;
public void setValue(Address value)
{
this.line1 = value.line1;
this.city = value.city;
this.zip = value.zip;
}
public Address getValue()
{
Address a = new Address();
this.a.line1 = this.line1;
this.a.city = this.city;
this.a.zip = this.zip;
return a;
}
}
Probably neither, though both technically could work.
A LeafValueEditor is an Editor for leaf values - that is, values that don't generally contain other values. Usually a text or date or number field that would be visible on the page is the leaf editor, and those leaf nodes are contained in a normal Editor.
In this case, it could look something like this:
public class AddressEditor extends Composite implements Editor<Address> {
// not private, fields must be visible for the driver to manipulate them
// automatically, could be package-protected, protected, or public
protected TextBox line1;//automatically maps to getLine1()/setLine1(String)
protected TextBox city;
protected TextBox zip;
public AddressEditor() {
//TODO build the fields, attach them to some parent, and
// initWidget with them
}
}
See http://www.gwtproject.org/doc/latest/DevGuideUiEditors.html#Editor_contract for more details on how this all comes together automatically with just that little wiring.

Drools log file

I have tried and unable to find a document that describes the attributes in Drools log file. For example, in below HelloWorld example log what is type?
<org.drools.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>Hello World [1]</activationId>
<rule>Hello World</rule>
<declarations>m=com.sample.DroolsTest$Message#19a01f9(1)</declarations>
</org.drools.audit.event.ActivationLogEvent>
From ActivationLogEvent.java:
#param type The type of event. This can only be ACTIVATION_CREATED, ACTIVATION_CANCELLED, BEFORE_ACTIVATION_FIRE or AFTER_ACTIVATION_FIRE.
From LogEvent.java:
public static final int ACTIVATION_CREATED = 4;
public static final int ACTIVATION_CANCELLED = 5;
public static final int BEFORE_ACTIVATION_FIRE = 6;
public static final int AFTER_ACTIVATION_FIRE = 7;
So I guess your event is an ACTIVATION_CREATED event.