Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SONAR: code quality for 13 release #9772

Closed
Rapster opened this issue Feb 7, 2023 · 15 comments · Fixed by #10246
Closed

SONAR: code quality for 13 release #9772

Rapster opened this issue Feb 7, 2023 · 15 comments · Fixed by #10246
Assignees
Labels
enhancement Additional functionality to current component
Milestone

Comments

@Rapster
Copy link
Member

Rapster commented Feb 7, 2023

Description

The codebase might need some attention since last time we focused on this, on this day:

  • 131 critical
  • 87 major

More details here: https://sonarcloud.io/project/issues?resolved=false&id=org.primefaces%3Aprimefaces

I see a lot of Make "XXX" transient or serializable" kind of errors, and I think it'd be great to know once and for all what to do with these warnings?

The rest should be quite easy to fix. If you have any questions, suggestions, feel free to share 😉

Describe the solution you would like

See how we can split the work (it's redundant work and not so fun 😅 )

Additional context

Also I see we have some singletons for DT/TT features, I'm planning to remove those for many reasons (essentially it's an anti-pattern, and we don't need to define them as singleton)

@Rapster Rapster added the enhancement Additional functionality to current component label Feb 7, 2023
@melloware
Copy link
Member

I will let Thomas answer the "transient" question but I am all for helping split the work and fixing the others!

@tandraschko
Copy link
Member

tandraschko commented Feb 8, 2023

TBH i would fix some cases where we know for sure that it can NEVER be serializable but after that i would propably just ignore (remove the rule) the "make XXX transient or serializable"
why?
We cant make all fields serializable" e.g. UIComponents are not serializable, so we have to make it transient
For other fields like TreeNode and we should not force a user to make everything serializable

because also JSF itself doesnt serializable the event but the user might - and it might even just works for the most cases, when the user itself e.g. serialize NodeCollapseEvent and the user applied a serializable TreeNode
if serialization fails, then he need just to implement serializeable in its own TreeNode

if we make it transient, the user will never have the coiche to serialize it

@Rapster
Copy link
Member Author

Rapster commented Feb 8, 2023

Ok as long we have a good reason to do it I'm cool with that, I've disabled this rule then

We have 20 critical now just by removing this rule 😅

Rapster added a commit to Rapster/primefaces that referenced this issue Feb 10, 2023
@melloware melloware added this to the 13.0.0 milestone Feb 11, 2023
@Rapster Rapster reopened this Feb 13, 2023
@Rapster
Copy link
Member Author

Rapster commented Feb 13, 2023

16 critical and 66 Major left. I'm having a look at ImageCropperRenderer. We have a lot of Remove usage of generic wildcard type. not sure yet how to deal with those

@tandraschko
Copy link
Member

i would disable this rule until a user comes up with a related problem someday; we never had any problems

@tandraschko
Copy link
Member

i also wonder about java:S2160
we would need to overwrite equals/hashcode and just delegate to the parent (e.g. DotEndPoint)
i dont like that TBH, i would also ignore it

i think this are rules for "normal projects", not for OS frameworks which gets reviews from X people

@melloware
Copy link
Member

I agree about the Generics warning I think we should just disable it.

@tandraschko
Copy link
Member

will also fix some java:S1181 and deactivate the rule
its by design to catch Throwable

@Rapster
Copy link
Member Author

Rapster commented Feb 13, 2023

S2160 makes sense (maybe less relevant in DotEndPoint and co.) but in general I would definitely keep it (specially when it comes to POJOs)

S1452: maybe exclude that rule for org.primefaces.component package (trying to solve that squid can result into ugly stuff, I didn't try, but looking at a component like DataTable, quickly can have a snowball effect)

S1181: how is it by design?

@tandraschko
Copy link
Member

S2160: we can add it back but how can we exclude this for this specific classes? i dont like to add something like //CHECKSTYLE:OFF
currently i dont see any case where we should really do it

S1181: we have currently 2 cases only and this can throw a LinkageError/NoClassDefFound

melloware added a commit to melloware/primefaces that referenced this issue Apr 14, 2023
melloware added a commit that referenced this issue Apr 14, 2023
Rapster added a commit to Rapster/primefaces that referenced this issue Apr 16, 2023
@tandraschko tandraschko reopened this Apr 18, 2023
Rapster added a commit to Rapster/primefaces that referenced this issue May 7, 2023
@jepsar
Copy link
Member

jepsar commented Jun 16, 2023

This change will break premium templates. They (or at least Diamond) come with a custom menu component. In the renderer they do:

        WidgetBuilder wb = getWidgetBuilder(context);
        wb.init("Diamond", menu.resolveWidgetVar(), clientId)
                .attr("statefulScroll", menu.isStatefulScroll());
        wb.finish();

Which no longer works, because init is now private:

https://github.com/primefaces/primefaces/blame/cdd2511c9c786f2fedcec4fa784e625d8f8718e3/primefaces/src/main/java/org/primefaces/util/WidgetBuilder.java#L85

@melloware
Copy link
Member

melloware commented Jun 16, 2023

Yep that could just just be..

WidgetBuilder wb = getWidgetBuilder(context);
wb.init("Diamond", menu).attr("statefulScroll", menu.isStatefulScroll());
wb.finish();

@jepsar
Copy link
Member

jepsar commented Jun 16, 2023

I was about to post that 👍🏻. I'll update the forum thread.

@Rapster
Copy link
Member Author

Rapster commented Jun 16, 2023

That's another reason why PrimeTek should put their templates into private repositories, that would help everyone...

@tandraschko
Copy link
Member

did we remove it during 13?
if yes, we can also deprecate first to make migration easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additional functionality to current component
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants