PR# 19295 Incorrect report of code analysis rule CA020 violation

Problem Report Summary
Submitter: prestoat2000
Category: EiffelStudio
Priority: Low
Date: 2016/11/18
Class: Bug
Severity: Non-critical
Number: 19295
Release: 16.11.99804
Confidential: No
Status: Closed
Responsible: alexk_es
Environment: linux
Synopsis: Incorrect report of code analysis rule CA020 violation

The Eiffel Inspector reports a CA020 violation (variable not read after assignment).  It is true that
the variable is not read after assignment, but the called function has a side effect so removing the
assignment would break the code.

Here is the assignment:

   cel := make_one_cell("\", 1, 1, false)

And the function is:

       make_one_cell(txt: STRING; row, col: INTEGER; hdr: BOOLEAN):
                -- row and col are MY_TABLE indices
	        -- txt is the text
	do  create Result.make(txt);
	    if hdr then Result.set_as_header end;
	    my_table.put(Result, row, col)

Note the call to my_table.put (side effect).

This is probably not a good way to write the code, but the inspector should not report a violation if the called
function has side effects.
To Reproduce

Problem Report Interactions
From:alexk_es    Date:2018/10/23    Status: Closed    Download   
Added test#code_analysis032.

Fixed in rev#102377 of EiffelStudio 18.11 intermediate release by reporting violation only when source expression is attached and an assignment

   target := source

can be replaced with


From:prestoat2000    Date:2016/11/21    Status: Analyzed    Download   
Yes, I think suggesting a call to `do_nothing'  in the attached case would be fine.

From:alexk_es    Date:2016/11/19    Status: Analyzed    Download   
Thank you for your report. Would it be reasonable to suggest replacing an assignment with a call to `do_nothing` if the return type is attached? (Unfortunately there is no good replacement yet for the case when the return type is detachable.)