Drapegnik/bsu

View on GitHub
programming/java/sem6/lab3/src/app/backend/dbDriver.java

Summary

Maintainability
D
2 days
Test Coverage

Method getStudents has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public ArrayList<Student> getStudents() {
        System.out.println("[dbDriver] Select students...");
        ArrayList<Student> data = new ArrayList<>();
        try {
            res = stmt.executeQuery(GET_STUDENTS);
Severity: Minor
Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java - About 1 hr to fix

    Method close has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private void close() {
            try {
                if (stmt != null)
                    stmt.close();
            } catch (SQLException se2) {
    Severity: Minor
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method getStudents has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public ArrayList<Student> getStudents() {
            System.out.println("[dbDriver] Select students...");
            ArrayList<Student> data = new ArrayList<>();
            try {
                res = stmt.executeQuery(GET_STUDENTS);
    Severity: Minor
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public ArrayList<Student> getStudents() {
            System.out.println("[dbDriver] Select students...");
            ArrayList<Student> data = new ArrayList<>();
            try {
                res = stmt.executeQuery(GET_STUDENTS);
    Severity: Major
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 4 hrs to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 191..229

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 303.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public ArrayList<String> getBadStudentsIds() {
            System.out.println("[dbDriver] Select bad students...");
            ArrayList<String> data = new ArrayList<>();
            try {
                res = stmt.executeQuery(GET_BAD_STUDENTS);
    Severity: Major
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 2 hrs to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 237..257

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 151.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public void initDB() {
            System.out.println("[dbDriver] Init database...");
            ArrayList<Student> data = Student.readFromFile(Options.STUDENTS_FILE_NAME);
            Random random = new Random();
    
    
    Severity: Major
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 2 hrs to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 288..304

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 133.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private void connect() {
            try {
                Class.forName(Options.JDBC_DRIVER);
                System.out.println("[dbDriver] Connecting to database...");
                conn = DriverManager.getConnection(Options.DB_URL + Options.DB_NAME, Options.DB_USER, Options.DB_PASS);
    Severity: Major
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 1 hr to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 68..80

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 111.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private void close() {
            try {
                if (stmt != null)
                    stmt.close();
            } catch (SQLException se2) {
    Severity: Major
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 1 hr to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 326..349

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 109.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private void dropDB() {
            try {
                System.out.println("[dbDriver] Drop database...");
                sql = "DROP DATABASE IF EXISTS " + Options.DB_NAME;
                stmt.executeUpdate(sql);
    Severity: Major
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 1 hr to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 135..148

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 101.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        public void createMark(Mark mark) {
            try {
                stmt = conn.createStatement();
                pstmt = conn.prepareStatement(CREATE_MARK);
                pstmt.setString(1, mark.getId());
    Severity: Major
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 1 hr to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 264..277

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 96.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        public void createStudent(Student student) {
            try {
                pstmt = conn.prepareStatement(CREATE_STUDENT);
                pstmt.setString(1, student.getId());
                pstmt.setString(2, student.getName());
    Severity: Major
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 1 hr to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 155..166

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 72.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public void deleteStudent(String id) {
            try {
                System.out.println("[dbDriver] Delete student...");
                pstmt = conn.prepareStatement(DELETE_STUDENT);
                pstmt.setString(1, id);
    Severity: Major
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 1 hr to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 173..184

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 70.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private void createTable(String tableName, String sql) {
            System.out.println("[dbDriver] Creating table...");
    
            try {
                stmt.executeUpdate(sql);
    Severity: Minor
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 55 mins to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 87..96

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 65.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        private void createMarkTable() {
            String sql = "CREATE TABLE " + MarksTable +
                    "(id VARCHAR(255) not NULL, " +
                    " subject VARCHAR(255), " +
                    " grade INTEGER, " +
    Severity: Minor
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 35 mins to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 120..128

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        public void createStudentsTable() {
            String sql = "CREATE TABLE " + StudentsTable +
                    "(id VARCHAR(255) not NULL, " +
                    " s_name VARCHAR(255), " +
                    " s_group INTEGER, " +
    Severity: Minor
    Found in programming/java/sem6/lab3/src/app/backend/dbDriver.java and 1 other location - About 30 mins to fix
    programming/java/sem6/lab1/src/app/backend/sqlDriver.java on lines 105..112

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 41.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    There are no issues that match your filters.

    Category
    Status