Showing 1,390 of 1,390 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
constructor() {
super();
this._dragover_handler = this._dragover_handler.bind(this);
this._drop_handler = this._drop_handler.bind(this);
}
- Read upRead up
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 60.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function registerValidSW
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
Function constructor
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(props) {
super(props);
this.state = {
dispatched: false,
aliasId: props.match ? props.match.params.patientIdCreated : '',
Function _validateFields
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_validateFields() {
const { visitId } = this.props.match.params;
const { outcomeApplicable, pregnancyEntry } = this.state;
const { data } = this.props;
Function _handleSubmit
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_handleSubmit(ev) {
ev.preventDefault();
if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
return;
Function _handleSubmit
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_handleSubmit(ev) {
ev.preventDefault();
if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
return;
const { patientId } = this.props;
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { editing, diagnosisDate, diagnosis, diagnosisDate_original, diagnosis_original } = this.state;
const { data, diagnoses } = this.props;
return (
Function _formatEntries
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
static _formatEntries({ dataTableForeignKey, entryIdString }, { body, user }) {
const returned = {};
const numOfUpdates = (body.hasOwnProperty('update')) ? Object.keys(body.update).length : 0;
const numOfAdds = (body.hasOwnProperty('add')) ? Object.keys(body.add).length : 0;
const updates = [];
Function createWindow
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
toolbar: false,
show: false,
Function editPregnancyImage
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
static editPregnancyImage({ body, user }, res) {
//
if (body.hasOwnProperty('id') && typeof body.id === 'number') {
const entryObj = Object.assign({}, body);
Function getPatientProfile
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
static getPatientProfile(whereObj, deleted, getOnly) {
return new Promise((resolve, reject) => Patient.getPatient(whereObj, { patientId: 'id', alias: 'aliasId', optimiseConsent: 'optimiseConsent', pregnancySubStudyConsent: 'pregnancySubStudyConsent', participation: 'participation' }, deleted)
.then((Patientresult) => {
let patientId;
if (Patientresult.length === 1) {
Function _handleSubmitClick
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
_handleSubmitClick(e) {
e.preventDefault();
if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
return;
Function _handleSubmitClick
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
_handleSubmitClick(ev) {
ev.preventDefault();
if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
return;
Function mappingVisitFunction
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const mappingVisitFunction = visit => {
// const EDSSFieldID = this.props.visitFields.filter(field => field.idname === 'edss:expanded disability status scale - estimated total')[0].id;
// const EDSSRecord = visit.data.filter(record => record.field === EDSSFieldID);
Function render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { syncInfo } = this.props;
if (syncInfo.config === undefined || syncInfo.config.host === undefined || syncInfo.config.host === '')
return null;
Function _checkEntryOrder
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
static _checkEntryOrder(pregnancyEntry, data) {
let pregnancyId = pregnancyEntry.pregnancyId;
const currentVisit = data.visits.find(el => parseInt(el.id) === parseInt(pregnancyEntry.recordedDuringVisit));
const allPregnancyEntries = data.pregnancyEntries.filter((el) => parseInt(el.pregnancyId) === parseInt(pregnancyId));
Function render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
return (
<>
<div className={style.ariane}>
<Helmet title='Patient Search' />
Function formatEdss
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const formatEdss = (edssList, typeTable) => {
if (edssList.length === 0) {
return () => [
blockgen(''),
blockgen(edssTitle(), [{ offset: 0, length: 11, style: 'BOLD' }]),
Function _handleSubmit
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
_handleSubmit(ev) {
ev.preventDefault();
if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
return;
Similar blocks of code found in 3 locations. Consider refactoring. Open
visit.route('/')
.get(VisitController.getVisitsOfPatient)
.post(VisitController.createVisit)
.put(VisitController.updateVisit)
.delete(VisitController.deleteVisit);
- Read upRead up
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 59.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76