Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disable-mutants comments #49

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,7 @@
### React.memo + useCallback optimization

[Pull request](https://github.com/nickovchinnikov/minesweeper/pull/47/files)

### Stryker disable mutants

[Pull request](https://github.com/nickovchinnikov/minesweeper/pull/49/files)
1 change: 1 addition & 0 deletions src/components/Grid/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const Cell: FC<CellProps> = memo(({ children, coords, ...rest }) => {
return <ComponentsMap {...props}>{children}</ComponentsMap>;
}, areEqual);

// Stryker disable next-line StringLiteral
Cell.displayName = 'Cell';

interface ComponentsMapProps {
Expand Down
1 change: 1 addition & 0 deletions src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const Grid: FC<GridProps> = ({ children, ...rest }) => (
<Wrapper size={children.length} role="grid">
{children.map((row, y) =>
row.map((cell, x) => (
// Stryker disable next-line StringLiteral
<Cell key={`${y}_${x}_${cell}`} coords={[y, x]} {...rest}>
{cell}
</Cell>
Expand Down
1 change: 1 addition & 0 deletions src/components/Scoreboard/Counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const Counter: FC<CounterProps> = memo(({ children }) => (
<Frame>{children}</Frame>
));

// Stryker disable next-line StringLiteral
Counter.displayName = 'Counter';

const Frame = styled.div`
Expand Down
1 change: 1 addition & 0 deletions src/components/Scoreboard/Level.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const Level: FC<LevelProps> = memo(({ children, value, onChange }) => (
</Select>
));

// Stryker disable next-line StringLiteral
Level.displayName = 'Level';

const Select = styled.select`
Expand Down
1 change: 1 addition & 0 deletions src/components/Scoreboard/Reset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const Reset: FC<ResetProps> = memo(({ onReset }) => {
);
});

// Stryker disable next-line StringLiteral
Reset.displayName = 'Reset';

const Button = styled.button`
Expand Down
1 change: 1 addition & 0 deletions src/components/Top/Top.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const Top: FC<TopComponentType> = memo(
)
);

// Stryker disable next-line StringLiteral
Top.displayName = 'Top';

const Header = styled.header`
Expand Down
17 changes: 10 additions & 7 deletions src/components/hooks/useMouseDown.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useDebugValue } from 'react';
import { useState, useCallback } from 'react';

export type SetMouseDownStatus = () => void;
export type SetMouseUpStatus = () => void;
Expand All @@ -10,13 +10,16 @@ export const useMouseDown = (): [
] => {
const [mouseDown, setMouseDown] = useState(false);

useDebugValue(
`mouseDown: ${mouseDown}`,
(str) => `${str} ${new Date().toISOString()}`
const onMouseDown = useCallback(
() => setMouseDown(true),
// Stryker disable next-line ArrayDeclaration
[]
);
const onMouseUp = useCallback(
() => setMouseDown(false),
// Stryker disable next-line ArrayDeclaration
[]
);

const onMouseDown = () => setMouseDown(true);
const onMouseUp = () => setMouseDown(false);

return [mouseDown, onMouseDown, onMouseUp];
};
2 changes: 2 additions & 0 deletions src/core/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export const fieldGenerator = (size: number, probability: number): Field => {

const result: Field = generateFieldWithDefaultState(size);

// Stryker disable next-line EqualityOperator
for (let y = 0; y < size; y++) {
for (let x = 0; x < size; x++) {
// Stryker disable next-line EqualityOperator
if (restCellsWithBombs / unprocessedCells > Math.random()) {
result[y][x] = CellState.bomb;
incrementNeibours([y, x], result);
Expand Down
1 change: 1 addition & 0 deletions src/modules/GameWithHooks/GameWithHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const GameWithHooks: FC = () => {
const onChangeLevelHandler = useCallback(
({ target: { value: level } }: React.ChangeEvent<HTMLSelectElement>) =>
onChangeLevel(level as LevelNames),
// Stryker disable next-line ArrayDeclaration
[]
);

Expand Down
7 changes: 6 additions & 1 deletion src/modules/GameWithHooks/useGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ export const useGame = (): ReturnType => {
const onChangeLevel = useCallback((level: LevelNames) => {
const newSettings = setLevel(level);
resetHandler(newSettings);
// Stryker disable next-line ArrayDeclaration
}, []);

const onReset = useCallback(() => resetHandler([size, bombs]), [size, bombs]);
const onReset = useCallback(
() => resetHandler([size, bombs]),
// Stryker disable next-line ArrayDeclaration
[size, bombs]
);

return {
level,
Expand Down