Skip to content

Organise imports places @Timeout in the wrong position #3598

@bsutton

Description

@bsutton

If you are using the test package you are able to add an @timeout annotation to the top of a library to indicate a longer than default timeout for the tests.

The @timeout annotation MUST be at the top of the file.

If you have the @timeout annotation and run 'Organise Imports' the @timeout annotation often gets moved down in amongst the imports and in some cases is completely deleted.

This causes an error an you have to manually move the annotation back to the top of the file or worse still removes it all together and if it is deleted you may not even realise it has been deleted.

Delete Example
In this example 'dart:io' is an unused package. Running organise imports removes dart:io and also @timeout

@Timeout(Duration(minutes: 20))
import 'dart:io';
import 'package:dcli/dcli.dart' hide equals;
import 'package:nginx_le_container/src/util/acquisition_manager.dart';
import 'package:nginx_le_shared/nginx_le_shared.dart';
import 'package:test/test.dart';

After organize imports:

import 'package:dcli/dcli.dart' hide equals;
import 'package:nginx_le_container/src/util/acquisition_manager.dart';
import 'package:nginx_le_shared/nginx_le_shared.dart';
import 'package:test/test.dart';

Move example
The 'dart:io' package is in the wrong place

@Timeout(Duration(minutes: 20))

import 'package:dcli/dcli.dart' hide equals;
import 'package:nginx_le_container/src/util/acquisition_manager.dart';
import 'package:nginx_le_shared/nginx_le_shared.dart';
import 'package:test/test.dart';
import 'dart:io';
import 'mock_cerbot_paths.dart';

In this scenario the @timeout annotation ends up:

import 'dart:io';

@Timeout(Duration(minutes: 20))
import 'package:dcli/dcli.dart' hide equals;
import 'package:nginx_le_container/src/util/acquisition_manager.dart';
import 'package:nginx_le_shared/nginx_le_shared.dart';
import 'package:test/test.dart';

import 'mock_cerbot_paths.dart';

Not exactly a critical bug, but annoying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions