Showing 42 of 42 total issues
File PaintCanvas.tsx
has 359 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Color } from 'csstype';
import * as React from 'react';
import { AnimationFrameId, appSpace, between, emptyPos, IPos, IPosPair, Ratio } from '../../misc';
import MultiPointerHandler from '../../services/MultiPointerHandler';
import './PaintCanvas.css';
PaintCanvas
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
class PaintCanvas extends React.Component<IPaintCanvasProps, IPaintCanvasState> {
protected refCanvas = React.createRef<HTMLCanvasElement>();
protected tmPressing: AnimationFrameId = 0;
protected lastPos: IPos = emptyPos;
protected lined = false;
File PaintPage.tsx
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
// import * as firebase from 'firebase';
import { Color } from 'csstype';
import * as React from 'react';
import { connect } from 'react-redux';
import BubbleButton from '../../components/BubbleButton';
Identical blocks of code found in 2 locations. Consider refactoring. Open
protected async fetchList (): Promise<IImageRecord[]> {
if (this.currentUser) {
this.setState({ loadingImages: true });
const images = await image.fetchList(this.currentUser.uid);
this.setState({ loadingImages: false });
- 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 98.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
protected async fetchList (): Promise<image.IImageRecord[]> {
if (this.currentUser) {
this.setState({ loadingImages: true });
const images = await image.fetchList(this.currentUser.uid);
this.setState({ loadingImages: false });
- 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 98.
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 getOrientation
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getOrientation (file: File): Promise<ExifOrientation> {
// TODO check why this is called twice
const jpeg = 0xffd8;
const exifMarker = 0xffe1;
PointerHandler
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
export default class PointerHandler {
protected props: IPointerHandlerProps;
protected state: IPointerHandlerState;
protected el: HTMLElement | null = null;
protected pointStartedPos: IPos = emptyPos;
Function render
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public render () {
const onChange = this.onChange.bind(this);
const onSubmitNew = this.onSubmitNew.bind(this);
const onFileChange = this.onFileChange.bind(this);
const records = this.state.imageRecords;
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (file && imageUtil.isImageFile(file)) {
const stop = this.props.startProcessing();
try {
await this.loadImage(file);
} finally {
- 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 82.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (file && imageUtil.isImageFile(file)) {
const stop = this.props.startProcessing();
try {
await this.loadImage(file);
} finally {
- 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 82.
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
PaintPage
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class PaintPage extends React.Component<IPaintPagePros, IPaintPageState> {
protected currentUser: firebase.User | null = null;
protected elCanvas: HTMLCanvasElement | null = null;
protected storageRef = firebase.storage().ref('v1-images');
protected canvasType = '';
Function applyImageOrientation
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function applyImageOrientation (image: HTMLImageElement, orientation: ExifOrientation): Promise<HTMLImageElement> {
const width = image.naturalWidth;
const height = image.naturalHeight;
const canvas = document.createElement('canvas');
Function render
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public render () {
const s = this.state;
const onEditClick = this.onEditClick.bind(this);
const onScaleChange = this.onScaleChange.bind(this);
const onFileChange = this.onFileChange.bind(this);
Function getOrientation
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export async function getOrientation (file: File): Promise<ExifOrientation> {
// TODO check why this is called twice
const jpeg = 0xffd8;
const exifMarker = 0xffe1;
- Read upRead up
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 render
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public render () {
return (
<div className="PaintPage">
{!this.state.imageLoading && <PaintCanvas
height={this.state.height}
Function render
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public render () {
const records = this.state.imageRecords;
return (
<div className="HistoryPage">
Function calculateProperPos
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected calculateProperPos (pos: IPos): IPos {
const el = this.el.current;
if (!el || !el.offsetParent) {
throw new Error('Element has to be mounted');
}
Function render
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public render () {
return (
<div className="HomePage">
<AppHeader/>
<div className="container" lang="ja">
Function renderMainContent
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected renderMainContent () {
return (
<PaintMenuContent>
<PaintMenuBody>
<div className="PaintMenu-close">
Function render
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public render () {
const title = this.props.title || 'Sorry, something went wrong... X(';
const ignoreBlock = !this.props.onIgnore ? undefined : (
<p className="ErrorOverlay-ignoreBlock">