ilscipio/scipio-erp

View on GitHub
framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java

Summary

Maintainability
F
3 days
Test Coverage

DatabaseUtil has 63 methods (exceeds 20 allowed). Consider refactoring.
Open

public class DatabaseUtil {

    private static final Debug.OfbizLogger module = Debug.getOfbizLogger(java.lang.invoke.MethodHandles.lookup().lookupClass());
    // SCIPIO
    private static final List<String> POSTGRES_FIELDTYPENAMES = UtilMisc.unmodifiableArrayList("postgres", "postnew");
Severity: Major
Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 1 day to fix

    Method checkDb has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public void checkDb(Map<String, ModelEntity> modelEntities, List<String> colWrongSize, List<String> messages, boolean checkPks, boolean checkFks, boolean checkFkIdx, boolean addMissing) {
    Severity: Major
    Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 50 mins to fix

      Method createPrimaryKeyFetcher has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private AbstractCountingCallable createPrimaryKeyFetcher(final DatabaseMetaData dbData, final String lookupSchemaName, final boolean needsUpperCase, final Map<String, Map<String, ColumnCheckInfo>> colInfo, final Collection<String> messages, final String curTable) {
      Severity: Minor
      Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                        if (fieldDefs.length > 0) {
                                            List<ModelIndex.Field> indexFields = new ArrayList<>();
        
                                            for(String fieldDef : fieldDefs) {
                                                String colName = fieldDef;
        Severity: Major
        Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (addMissing) {
                                      // add the column
                                      String errMsg = addColumn(entity, field);
          
                                      if (UtilValidate.isNotEmpty(errMsg)) {
          Severity: Major
          Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (messages != null) messages.add(message);
            Severity: Major
            Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

              Method createForeignKeys has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public int createForeignKeys(ModelEntity entity, Map<String, ModelEntity> modelEntities, int constraintNameClipLength, String fkStyle, boolean useFkInitiallyDeferred, List<String> messages) {
              Severity: Minor
              Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

                Method makeFkConstraintClause has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public String makeFkConstraintClause(ModelEntity entity, ModelRelation modelRelation, ModelEntity relModelEntity, int constraintNameClipLength, String fkStyle, boolean useFkInitiallyDeferred) {
                Severity: Minor
                Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for (ColumnCheckInfo ccInfo: colMap.values()) {
                                              // -list all columns that do not have a corresponding field
                                              if (fieldColNames.containsKey(ccInfo.columnName)) {
                                                  ModelField field = null;
                  
                  
                  Severity: Major
                  Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

                    Method createForeignKey has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public String createForeignKey(ModelEntity entity, ModelRelation modelRelation, ModelEntity relModelEntity, int constraintNameClipLength, String fkStyle, boolean useFkInitiallyDeferred) {
                    Severity: Minor
                    Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if (colMap.size() != entity.getFieldsSize()) {
                                                  String message = "Entity [" + entity.getEntityName() + "] has " + entity.getFieldsSize() + " fields but table [" + tableName + "] has " + colMap.size() + " columns.";
                                                  Debug.logWarning(message, module);
                                                  if (messages != null) messages.add(message);
                                              }
                      Severity: Major
                      Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                        if (!modelIndex.isAutoIndex()) {
                                                            ModelIndex dbIndex = readModelIndexFromDb(entity, modelIndex);
                                                            if (dbIndex == null) {
                                                                // Not be supported on all DBs
                                                                //Debug.logWarning("Could not read entity [" + entityName + "] index [" + modelIndex.getName() +
                        Severity: Major
                        Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 45 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                              if (tableType != null && !"TABLE".equalsIgnoreCase(tableType) && !"VIEW".equalsIgnoreCase(tableType)
                                                      && !"ALIAS".equalsIgnoreCase(tableType) && !"SYNONYM".equalsIgnoreCase(tableType) && !"BASE TABLE".equalsIgnoreCase(tableType)) {
                                                  continue;
                                              }
                          Severity: Major
                          Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 40 mins to fix

                            Method checkPrimaryKeyInfo has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                public int checkPrimaryKeyInfo(ResultSet rsPks, String lookupSchemaName, boolean needsUpperCase, Map<String, Map<String, ColumnCheckInfo>> colInfo, Collection<String> messages) throws SQLException {
                            Severity: Minor
                            Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 35 mins to fix

                              Method getConnection has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  private Connection getConnection(String driverName, String connectionUrl, Properties props, String userName, String password) throws SQLException {
                              Severity: Minor
                              Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 35 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return null;
                                Severity: Major
                                Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return errMsg;
                                  Severity: Major
                                  Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return null;
                                    Severity: Major
                                    Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return null;
                                      Severity: Major
                                      Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return errMsg;
                                        Severity: Major
                                        Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return errMsg;
                                          Severity: Major
                                          Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                            return null;
                                            Severity: Major
                                            Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                          return dbIndex;
                                              Severity: Major
                                              Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                        return message;
                                                Severity: Major
                                                Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return null;
                                                  Severity: Major
                                                  Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                            return null;
                                                    Severity: Major
                                                    Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                      return errMsg;
                                                      Severity: Major
                                                      Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                return message;
                                                        Severity: Major
                                                        Found in framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java - About 30 mins to fix

                                                          There are no issues that match your filters.

                                                          Category
                                                          Status