Rambou/icarus-sef-parser

View on GitHub

Showing 14 of 38 total issues

File index.js has 525 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// import dependencies
var request = require('request'),
    charsetParser = require('charset-parser'),
    iconv = require('iconv-lite'),
    jsdom = require("jsdom");
Severity: Major
Found in lib/index.js - About 1 day to fix

Function postRequestToDepartment has 131 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.postRequestToDepartment = function (data, cookie, callback) {
    var formData = {};

    if (this.department === DEPART.MPES) {

Severity: Major
Found in lib/index.js - About 5 hrs to fix

Function postRequestToDepartment has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

Parser.prototype.postRequestToDepartment = function (data, cookie, callback) {
    var formData = {};

    if (this.department === DEPART.MPES) {

Severity: Minor
Found in lib/index.js - About 4 hrs 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

Function getCurriculumToDeclare has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.getCurriculumToDeclare = function (cookie, callback) {

    request({
        url: this.department.url + '/student_dilosi.php', method: 'GET',
        headers: {'Cookie': cookie},
Severity: Major
Found in lib/index.js - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

        if (data.id === null || data.surname === null ||
            data.name === null || data.father === null ||
            data.semester === null || data.address === null ||
            data.phone === null || data.method === null ||
            data.sent_address === null || data.requests === null)
Severity: Critical
Found in lib/index.js - About 2 hrs to fix

Function getSucceededGrades has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.getSucceededGrades = function (document, callback) {
    var courses = [];

    try {
        if (this.department === DEPART.MPES) {
Severity: Minor
Found in lib/index.js - About 1 hr to fix

Function getAnalyticGrades has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.getAnalyticGrades = function (document, callback) {
    var courses = [];

    try {
        if (this.department === DEPART.MPES) {
Severity: Minor
Found in lib/index.js - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

        if (data.requests === null || data.address === null ||
            data.address2 === null || data.id === null || data.emergency === null ||
            data.father === null || data.name === null || data.other === null ||
            data.surname === null)
            return callback(new Error("JSON data is in wrong format."), null);
Severity: Critical
Found in lib/index.js - About 1 hr to fix

Function getUserDetails has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.getUserDetails = function (document, cookie, callback) {
    if (this.department === DEPART.MPES) {
        try {
            var student_name = document.window.document.querySelector('#header_login u').innerHTML;
            var student_id = document.window.document.querySelector('#tabs-1 h2').innerHTML.replace('Μητρώο φοιτητή: ', '').replace(/ -.*/i, '').trim();
Severity: Minor
Found in lib/index.js - About 1 hr to fix

Function authenticate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.authenticate = function (callback) {
    this.getCookie(function (error, cookie) {
        if (error)
            return callback(error, null);

Severity: Minor
Found in lib/index.js - About 1 hr to fix

Function postCurriculumToDeclare has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.postCurriculumToDeclare = function (courses, cookie, callback) {
    var formData = {};

    if (this.department === DEPART.MPES) {
        formData.count_lessons_etous = "1";
Severity: Minor
Found in lib/index.js - About 1 hr to fix

Function getExamGrades has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.getExamGrades = function (document, callback) {
    var courses = [];

    try {
        if (this.department === DEPART.MPES) {
Severity: Minor
Found in lib/index.js - About 1 hr to fix

Function getIntercalaryExamGrades has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Parser.prototype.getIntercalaryExamGrades = function (document, callback) {
    var courses = [];

    try {
        if (this.department === DEPART.MPES) {
Severity: Minor
Found in lib/index.js - About 1 hr to fix

Function postCurriculumToDeclare has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Parser.prototype.postCurriculumToDeclare = function (courses, cookie, callback) {
    var formData = {};

    if (this.department === DEPART.MPES) {
        formData.count_lessons_etous = "1";
Severity: Minor
Found in lib/index.js - About 25 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

Severity
Category
Status
Source
Language