[jira] [Commented] (JSPWIKI-1153) Inline Variable

2021-09-24 Thread Jira


[ 
https://issues.apache.org/jira/browse/JSPWIKI-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17419637#comment-17419637
 ] 

Jürgen Weber commented on JSPWIKI-1153:
---

    x = method()

    return x;

versus

    return method();

 

The second is cooler and looks better, the first you can debug. You can set a 
breakpoint on the return line and see what is returned.

 

> Inline Variable
> ---
>
> Key: JSPWIKI-1153
> URL: https://issues.apache.org/jira/browse/JSPWIKI-1153
> Project: JSPWiki
>  Issue Type: Improvement
>Reporter: Arturo Bernal
>Priority: Minor
>  Labels: pull-request-available
>
> Remove unnecessary local variables that are immediately returned or are 
> immediately assigned to another variable and then not used.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (JSPWIKI-1154) Replace ´if´ with switch statements.

2021-09-24 Thread Arturo Bernal (Jira)
Arturo Bernal created JSPWIKI-1154:
--

 Summary: Replace ´if´  with switch statements.
 Key: JSPWIKI-1154
 URL: https://issues.apache.org/jira/browse/JSPWIKI-1154
 Project: JSPWiki
  Issue Type: Improvement
Reporter: Arturo Bernal


Replace ´if´ with switch statements.. The replacement result is usually shorter 
and clearer.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JSPWIKI-1153) Inline Variable

2021-09-24 Thread Jira


[ 
https://issues.apache.org/jira/browse/JSPWIKI-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17419995#comment-17419995
 ] 

Juan Pablo Santos Rodríguez commented on JSPWIKI-1153:
--

I've got to take a closer look at the PR, but seems that in this case inlined 
variables are either constructed and returned
{code:java}
final VariableInfo[] var = { new VariableInfo( data.getAttributeString("id"), 
   
"org.apache.wiki.ui.admin.AdminBean",
   true,
   VariableInfo.NESTED )
};
return var;
{code}
vs
{code:java}
return new VariableInfo[] { new VariableInfo( data.getAttributeString("id"),
  
"org.apache.wiki.ui.admin.AdminBean",
  true,
  VariableInfo.NESTED )
};
{code}
or objects holding references to existing objects
{code}
for ( String s : ... ) {
String f = s;
...
}
{code}

or objects built from simple calls to other objects and then returned
{code}
final Method m = clazz.getDeclaredMethod( name, parm != null ? params : 
emptyparms );
return m;
{code}

I think that inlining makes sense in those cases, as the code is easier to 
follow; however, if there were any cases such as 
{code}
x =  veryComplexMethod()
return x;
{code}
I'd be +1 on not inlining it, but let's take a proper look at the PR

> Inline Variable
> ---
>
> Key: JSPWIKI-1153
> URL: https://issues.apache.org/jira/browse/JSPWIKI-1153
> Project: JSPWiki
>  Issue Type: Improvement
>Reporter: Arturo Bernal
>Priority: Minor
>  Labels: pull-request-available
>
> Remove unnecessary local variables that are immediately returned or are 
> immediately assigned to another variable and then not used.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)