Created: 2026-03-24 mar 20:03
/** */ con texto libre@author |
Autor o autores del bloque de código |
@code |
Similar a <pre></pre> |
@deprecated |
El método/clase se eliminará en un futuro |
@link |
Enlace a página web |
@param |
Argumento que recibe un método. |
@return |
Valor de retorno del método |
@see |
Añade un comentario See Also |
@since |
Desde que versión está disponible |
@throws |
Explicación de excepciones lanzadas |
@version |
Versión actual del bloque código |
java.util.Set.contains() /**
* Returns {@code true} if this set contains the specified element.
* More formally, returns {@code true} if and only if this set
* contains an element {@code e} such that
* {@code Objects.equals(o, e)}.
*
* @param o element whose presence in this set is to be tested
* @return {@code true} if this set contains the specified element
* @throws ClassCastException if the type of the specified element
* is incompatible with this set
* (<a href="Collection.html#optional-restrictions">optional</a>)
* @throws NullPointerException if the specified element is null and this
* set does not permit null elements
* (<a href="Collection.html#optional-restrictions">optional</a>)
*/
boolean contains(Object o);
java.util.Arrays
CTRL-n ArrayList)Java-gamesGenera la documentación
javadoc -sourcepath src -d docs -subpackages <paquetes>
Para clases sin paquete:
javadoc -d docs src/*.java
(Lo que tiene relación con el manifiesto ágil: Software funcionando sobre documentación extensiva)
https://openwebinars.net/blog/code-smells-y-deuda-tecnica/
Si se detectan bloques de código iguales o muy parecidos en distintas partes del programa, se debe extraer creando un método para unificarlo.
public void leerCSV(String[] filas) {
for (String fila : filas) {
if (fila.isEmpty()) {
System.out.println("Aviso: fila vacía");
}
if (fila.length() < 3) {
System.out.println("Aviso: fila demasiado corta");
}
}
}
public void leerCSV(String[] filas) {
for (String fila : filas) {
if (fila.isEmpty()) {
aviso("fila vacía");
}
if (fila.length() < 3) {
aviso("fila demasiado corta");
}
}
}
private void aviso(String msg) {
System.out.println("Aviso: " + msg);
}
/** Encuentra los puntos de corte entre dos parábolas
* y = a1x² + b1x + c1
* y = a2x² + b2x + c2
*/
public static double[] puntosCorte(double a1, double b1, double c1, double a2, double b2, double c2) {
....
}
public class Parabola {
double a;
double b;
double c;
}
public static double[] puntosCorte(Parabola p1, Parabola p2) {
....
}
FallDownComponent.java@java.lang.SuppressWarnings("squid:S00112")
Ejemplo de instalación simplificada, no apta para trabajo serio
admin, contraseña admin (se puede cambiar por Contraseñacomplicada1) podman run -p 9000:9000 --name sonarqube docker.io/sonarqube:community
/home/alvaro/repos/Java-Games/FallDown por el directorio del proyectosonar.token por el token que se genere en el servidorpodman run --rm \
--volume /home/alvaro/repos/Java-Games/FallDown:/usr/src:ro \
--workdir /usr/src \
--network=host \
docker.io/sonarsource/sonar-scanner-cli \
-Dsonar.projectKey=java-games \
-Dsonar.java.binaries=bin \
-Dsonar.projectName='java-games' \
-Dsonar.exclusions=doc \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.token=sqp_0373d5cbb31d95200fa97cab4998315f14add870
CTRL-ALT-SHIFT-t| Rename… — Shift+F6 | Change Signature… — Ctrl+6 | Introduce Variable… — Alt+Shift+V |
| Introduce Constant… — Ctrl+Alt+C | Introduce Field… — Ctrl+Alt+F | Introduce Parameter… — Ctrl+Alt+P |
| Introduce Functional Parameter… — Ctrl+Alt+Shift+P | Introduce Functional Variable… | Introduce Parameter Object… |
| Extract Method… — Ctrl+Alt+M | Replace Method With Method Object… | Extract Delegate… |
| Extract Interface… | Extract Superclass… | Inline… — Ctrl+Alt+N |
| Find and Replace Code Duplicates… | Move Class… — F6 | Copy Class… — F5 |
| Safe Delete… — Alt+Delete | Pull Members Up… | Push Members Down… |
| Type Migration… — Ctrl+Shift+F6 | Make Static… | Convert To Instance Method… |
| Use Interface Where Possible… | Replace Inheritance with Delegation… | Encapsulate Fields… |
| Migrate Packages and Classes > | Invert Boolean… |
MathHero.java:36TetrisGrid.draw()FallDownEngine.affectBall() (solo cambiar ball al final)GameComponent()Division.problem y Division.solution
TetrisGrid.setWorkingBlock()Find and replace code duplicatesExtract methodPull members upExtract superclassIntroduce parameter objectOtros bad smells tienen soluciones combinadas, o maś complejas que una refactorización automática
Copilot: All subclasses of Enemy must use setSolution() and setProblem() if possible, instead of using their own fields.
#+include ./P.java src java
private mejor que protectedprotected mejor que publicfinal si es posible{ } más interno posible